{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "{\n",
    " \"cells\": [\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 16,\n",
    "   \"id\": \"cbe47eb3-b4d7-4edc-b0d6-3916ae92a8fb\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"import polars as pl\\n\",\n",
    "    \"from perspective.widget import PerspectiveWidget\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 29,\n",
    "   \"id\": \"50ca3d34-1f10-4cc7-8f3e-156994c87a55\",\n",
    "   \"metadata\": {\n",
    "    \"collapsed\": true,\n",
    "    \"jupyter\": {\n",
    "     \"outputs_hidden\": true\n",
    "    },\n",
    "    \"scrolled\": true\n",
    "   },\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (363, 18)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>1</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:33:37&quot;</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>4.05</td><td>34400.0</td><td>139320.0</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>-139342.29</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>2</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:34:24&quot;</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>3.65</td><td>38300.0</td><td>139795.0</td><td>22.37</td><td>0.0</td><td>1.38</td><td>0.0</td><td>-139818.75</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>3</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:36:30&quot;</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>6.54</td><td>21400.0</td><td>139956.0</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-139979.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>4</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:37:25&quot;</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>2.59</td><td>54000.0</td><td>139860.0</td><td>22.38</td><td>0.0</td><td>1.42</td><td>0.0</td><td>-139883.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>5</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:38:16&quot;</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>13.51</td><td>10400.0</td><td>140504.0</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-140526.48</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>359</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:31:53&quot;</td><td>&quot;002956&quot;</td><td>&quot;西麦食品&quot;</td><td>&quot;卖出&quot;</td><td>14.13</td><td>5000.0</td><td>70650.0</td><td>6.74</td><td>35.35</td><td>0.0</td><td>0.0</td><td>70607.91</td><td>0.000095</td><td>0.0005</td><td>0.0</td></tr><tr><td>360</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:39:57&quot;</td><td>&quot;603214&quot;</td><td>&quot;爱婴室&quot;</td><td>&quot;买入&quot;</td><td>15.84</td><td>3100.0</td><td>49104.0</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>-49109.51</td><td>0.000102</td><td>0.0</td><td>0.00001</td></tr><tr><td>361</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:40:55&quot;</td><td>&quot;300132&quot;</td><td>&quot;青松股份&quot;</td><td>&quot;买入&quot;</td><td>5.21</td><td>9600.0</td><td>50016.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-50021.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr><tr><td>362</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:43:13&quot;</td><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>&quot;买入&quot;</td><td>5.91</td><td>8400.0</td><td>49644.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49649.0</td><td>0.000101</td><td>0.0</td><td>0.0</td></tr><tr><td>363</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:44:45&quot;</td><td>&quot;002111&quot;</td><td>&quot;威海广泰&quot;</td><td>&quot;买入&quot;</td><td>9.24</td><td>5400.0</td><td>49896.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49901.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (363, 18)\\n\",\n",
    "       \"┌──────┬─────────┬─────────┬─────────┬───┬─────────┬─────────┬────────┬────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商    ┆ 交易日  ┆ 交易时  ┆ … ┆ 发生金  ┆ 手续费  ┆ 印花税 ┆ 过户费 │\\n\",\n",
    "       \"│ ---  ┆ ---     ┆ 期      ┆ 间      ┆   ┆ 额      ┆ 率      ┆ 率     ┆ 率     │\\n\",\n",
    "       \"│ u32  ┆ str     ┆ ---     ┆ ---     ┆   ┆ ---     ┆ ---     ┆ ---    ┆ ---    │\\n\",\n",
    "       \"│      ┆         ┆ date    ┆ str     ┆   ┆ f64     ┆ f64     ┆ f64    ┆ f64    │\\n\",\n",
    "       \"╞══════╪═════════╪═════════╪═════════╪═══╪═════════╪═════════╪════════╪════════╡\\n\",\n",
    "       \"│ 1    ┆ 湘财    ┆ 2022-07 ┆ 09:33:3 ┆ … ┆ -139342 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 7       ┆   ┆ .29     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 2    ┆ 湘财    ┆ 2022-07 ┆ 09:34:2 ┆ … ┆ -139818 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 4       ┆   ┆ .75     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 3    ┆ 湘财    ┆ 2022-07 ┆ 09:36:3 ┆ … ┆ -139979 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 0       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 4    ┆ 湘财    ┆ 2022-07 ┆ 09:37:2 ┆ … ┆ -139883 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 5       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 5    ┆ 湘财    ┆ 2022-07 ┆ 09:38:1 ┆ … ┆ -140526 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 6       ┆   ┆ .48     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ …    ┆ …       ┆ …       ┆ …       ┆ … ┆ …       ┆ …       ┆ …      ┆ …      │\\n\",\n",
    "       \"│ 359  ┆ 海通两  ┆ 2023-10 ┆ 09:31:5 ┆ … ┆ 70607.9 ┆ 0.00009 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 1       ┆ 5       ┆        ┆        │\\n\",\n",
    "       \"│ 360  ┆ 海通两  ┆ 2023-10 ┆ 09:39:5 ┆ … ┆ -49109. ┆ 0.00010 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 7       ┆   ┆ 51      ┆ 2       ┆        ┆ 1      │\\n\",\n",
    "       \"│ 361  ┆ 海通两  ┆ 2023-10 ┆ 09:40:5 ┆ … ┆ -50021. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 362  ┆ 海通两  ┆ 2023-10 ┆ 09:43:1 ┆ … ┆ -49649. ┆ 0.00010 ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 0       ┆ 1       ┆        ┆        │\\n\",\n",
    "       \"│ 363  ┆ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ … ┆ -49901. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"└──────┴─────────┴─────────┴─────────┴───┴─────────┴─────────┴────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 29,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"df = pl.read_parquet(\\\"stock_trades.parquet\\\")\\n\",\n",
    "    \"df = df.sort(\\\"交易日期\\\", \\\"交易时间\\\", \\\"证券代码\\\")\\n\",\n",
    "    \"df = df.with_columns(\\n\",\n",
    "    \"    pl.col(\\\"交易时间\\\").cast(pl.String),\\n\",\n",
    "    \"    手续费率=pl.col(\\\"手续费\\\") / pl.col(\\\"成交金额\\\"),\\n\",\n",
    "    \"    印花税率=pl.col(\\\"印花税\\\") / pl.col(\\\"成交金额\\\"),\\n\",\n",
    "    \"    过户费率=pl.col(\\\"过户费\\\") / pl.col(\\\"成交金额\\\"),\\n\",\n",
    "    \")\\n\",\n",
    "    \"\\n\",\n",
    "    \"df = df.with_row_index(\\\"序号\\\", 1)\\n\",\n",
    "    \"df\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 33,\n",
    "   \"id\": \"5e91d691-2d29-4ea1-8fc2-90566b67ed6f\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (2, 2)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>券商</th><th>count</th></tr><tr><td>str</td><td>u32</td></tr></thead><tbody><tr><td>&quot;海通普通&quot;</td><td>33</td></tr><tr><td>&quot;湘财&quot;</td><td>19</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (2, 2)\\n\",\n",
    "       \"┌──────────┬───────┐\\n\",\n",
    "       \"│ 券商     ┆ count │\\n\",\n",
    "       \"│ ---      ┆ ---   │\\n\",\n",
    "       \"│ str      ┆ u32   │\\n\",\n",
    "       \"╞══════════╪═══════╡\\n\",\n",
    "       \"│ 海通普通 ┆ 33    │\\n\",\n",
    "       \"│ 湘财     ┆ 19    │\\n\",\n",
    "       \"└──────────┴───────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 33,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"df.filter(pl.col(\\\"手续费\\\") < 5)[\\\"券商\\\"].value_counts()\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 34,\n",
    "   \"id\": \"bb04bba0-5d44-4e22-b4fc-3664e91a1c81\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (53, 18)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>320</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;09:34:39&quot;</td><td>&quot;300642&quot;</td><td>&quot;透景生命&quot;</td><td>&quot;卖出&quot;</td><td>18.106</td><td>2500.0</td><td>45266.0</td><td>5.0</td><td>45.26</td><td>0.0</td><td>0.0</td><td>45215.74</td><td>0.00011</td><td>0.001</td><td>0.0</td></tr><tr><td>323</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;09:39:25&quot;</td><td>&quot;600333&quot;</td><td>&quot;长春燃气&quot;</td><td>&quot;卖出&quot;</td><td>5.04</td><td>3900.0</td><td>19656.0</td><td>5.0</td><td>19.64</td><td>0.23</td><td>0.0</td><td>19631.13</td><td>0.000254</td><td>0.000999</td><td>0.000012</td></tr><tr><td>325</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;10:03:59&quot;</td><td>&quot;600525&quot;</td><td>&quot;长园集团&quot;</td><td>&quot;买入&quot;</td><td>4.88</td><td>8500.0</td><td>41480.0</td><td>5.0</td><td>0.0</td><td>0.35</td><td>0.0</td><td>-41485.35</td><td>0.000121</td><td>0.0</td><td>0.000008</td></tr><tr><td>327</td><td>&quot;海通两融&quot;</td><td>2023-09-01</td><td>&quot;10:22:36&quot;</td><td>&quot;300889&quot;</td><td>&quot;爱克股份&quot;</td><td>&quot;卖出&quot;</td><td>15.22</td><td>1500.0</td><td>22830.0</td><td>5.0</td><td>11.42</td><td>0.0</td><td>0.0</td><td>22813.58</td><td>0.000219</td><td>0.0005</td><td>0.0</td></tr><tr><td>329</td><td>&quot;海通两融&quot;</td><td>2023-09-01</td><td>&quot;10:23:28&quot;</td><td>&quot;300889&quot;</td><td>&quot;爱克股份&quot;</td><td>&quot;卖出&quot;</td><td>15.21</td><td>1700.0</td><td>25857.0</td><td>5.0</td><td>12.92</td><td>0.0</td><td>0.0</td><td>25839.08</td><td>0.000193</td><td>0.0005</td><td>0.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>322</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;09:36:13&quot;</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;卖出&quot;</td><td>9.36</td><td>10600.0</td><td>99216.0</td><td>10.91</td><td>99.24</td><td>1.0</td><td>0.0</td><td>99104.85</td><td>0.00011</td><td>0.001</td><td>0.00001</td></tr><tr><td>319</td><td>&quot;海通两融&quot;</td><td>2023-08-09</td><td>&quot;10:12:16&quot;</td><td>&quot;600336&quot;</td><td>&quot;澳柯玛&quot;</td><td>&quot;买入&quot;</td><td>5.72</td><td>17400.0</td><td>99528.0</td><td>10.95</td><td>0.0</td><td>1.0</td><td>0.0</td><td>-99539.95</td><td>0.00011</td><td>0.0</td><td>0.00001</td></tr><tr><td>324</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;09:58:46&quot;</td><td>&quot;603626&quot;</td><td>&quot;科森科技&quot;</td><td>&quot;买入&quot;</td><td>6.35</td><td>15700.0</td><td>99695.0</td><td>10.97</td><td>0.0</td><td>1.02</td><td>0.0</td><td>-99706.99</td><td>0.00011</td><td>0.0</td><td>0.00001</td></tr><tr><td>316</td><td>&quot;海通两融&quot;</td><td>2023-08-04</td><td>&quot;10:07:37&quot;</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;买入&quot;</td><td>9.43</td><td>10600.0</td><td>99958.0</td><td>11.0</td><td>0.0</td><td>1.01</td><td>0.0</td><td>-99970.01</td><td>0.00011</td><td>0.0</td><td>0.00001</td></tr><tr><td>340</td><td>&quot;海通两融&quot;</td><td>2023-09-12</td><td>&quot;14:31:39&quot;</td><td>&quot;603626&quot;</td><td>&quot;科森科技&quot;</td><td>&quot;卖出&quot;</td><td>7.43</td><td>15700.0</td><td>116651.0</td><td>11.13</td><td>58.32</td><td>1.17</td><td>0.0</td><td>116580.38</td><td>0.000095</td><td>0.0005</td><td>0.00001</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (53, 18)\\n\",\n",
    "       \"┌──────┬─────────┬─────────┬─────────┬───┬─────────┬─────────┬────────┬────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商    ┆ 交易日  ┆ 交易时  ┆ … ┆ 发生金  ┆ 手续费  ┆ 印花税 ┆ 过户费 │\\n\",\n",
    "       \"│ ---  ┆ ---     ┆ 期      ┆ 间      ┆   ┆ 额      ┆ 率      ┆ 率     ┆ 率     │\\n\",\n",
    "       \"│ u32  ┆ str     ┆ ---     ┆ ---     ┆   ┆ ---     ┆ ---     ┆ ---    ┆ ---    │\\n\",\n",
    "       \"│      ┆         ┆ date    ┆ str     ┆   ┆ f64     ┆ f64     ┆ f64    ┆ f64    │\\n\",\n",
    "       \"╞══════╪═════════╪═════════╪═════════╪═══╪═════════╪═════════╪════════╪════════╡\\n\",\n",
    "       \"│ 320  ┆ 海通两  ┆ 2023-08 ┆ 09:34:3 ┆ … ┆ 45215.7 ┆ 0.00011 ┆ 0.001  ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 9       ┆   ┆ 4       ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 323  ┆ 海通两  ┆ 2023-08 ┆ 09:39:2 ┆ … ┆ 19631.1 ┆ 0.00025 ┆ 0.0009 ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 5       ┆   ┆ 3       ┆ 4       ┆ 99     ┆ 12     │\\n\",\n",
    "       \"│ 325  ┆ 海通两  ┆ 2023-08 ┆ 10:03:5 ┆ … ┆ -41485. ┆ 0.00012 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 9       ┆   ┆ 35      ┆ 1       ┆        ┆ 08     │\\n\",\n",
    "       \"│ 327  ┆ 海通两  ┆ 2023-09 ┆ 10:22:3 ┆ … ┆ 22813.5 ┆ 0.00021 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -01     ┆ 6       ┆   ┆ 8       ┆ 9       ┆        ┆        │\\n\",\n",
    "       \"│ 329  ┆ 海通两  ┆ 2023-09 ┆ 10:23:2 ┆ … ┆ 25839.0 ┆ 0.00019 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -01     ┆ 8       ┆   ┆ 8       ┆ 3       ┆        ┆        │\\n\",\n",
    "       \"│ …    ┆ …       ┆ …       ┆ …       ┆ … ┆ …       ┆ …       ┆ …      ┆ …      │\\n\",\n",
    "       \"│ 322  ┆ 海通两  ┆ 2023-08 ┆ 09:36:1 ┆ … ┆ 99104.8 ┆ 0.00011 ┆ 0.001  ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 3       ┆   ┆ 5       ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 319  ┆ 海通两  ┆ 2023-08 ┆ 10:12:1 ┆ … ┆ -99539. ┆ 0.00011 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -09     ┆ 6       ┆   ┆ 95      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 324  ┆ 海通两  ┆ 2023-08 ┆ 09:58:4 ┆ … ┆ -99706. ┆ 0.00011 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 6       ┆   ┆ 99      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 316  ┆ 海通两  ┆ 2023-08 ┆ 10:07:3 ┆ … ┆ -99970. ┆ 0.00011 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -04     ┆ 7       ┆   ┆ 01      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 340  ┆ 海通两  ┆ 2023-09 ┆ 14:31:3 ┆ … ┆ 116580. ┆ 0.00009 ┆ 0.0005 ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -12     ┆ 9       ┆   ┆ 38      ┆ 5       ┆        ┆ 1      │\\n\",\n",
    "       \"└──────┴─────────┴─────────┴─────────┴───┴─────────┴─────────┴────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 34,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"df.filter(pl.col(\\\"券商\\\") == \\\"海通两融\\\").sort(\\\"手续费\\\")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 30,\n",
    "   \"id\": \"c3e88d8c-c161-4ed3-be72-14b5fa5332e3\",\n",
    "   \"metadata\": {\n",
    "    \"scrolled\": true\n",
    "   },\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"application/vnd.jupyter.widget-view+json\": {\n",
    "       \"model_id\": \"9e493d760a224e8b8d53d1c1d8273a54\",\n",
    "       \"version_major\": 2,\n",
    "       \"version_minor\": 0\n",
    "      },\n",
    "      \"text/plain\": [\n",
    "       \"PerspectiveWidget(binding_mode='server', columns=['序号', '券商', '交易日期', '交易时间', '证券代码', '证券名称', '买卖标志', '成交价格', …\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 30,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"PerspectiveWidget(df)\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 50,\n",
    "   \"id\": \"ef0a8ba7-5a19-4c02-82b1-193d60a4c50b\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"d1 = df.join(\\n\",\n",
    "    \"    df.group_by(\\\"证券代码\\\", \\\"证券名称\\\")\\n\",\n",
    "    \"    .agg(\\n\",\n",
    "    \"        结余数量=(\\n\",\n",
    "    \"            pl.when(pl.col(\\\"买卖标志\\\") == \\\"卖出\\\")\\n\",\n",
    "    \"            .then(-pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .when(pl.col(\\\"买卖标志\\\") == \\\"买入\\\")\\n\",\n",
    "    \"            .then(pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .sum()\\n\",\n",
    "    \"        ),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .filter(pl.col(\\\"结余数量\\\") < 0),\\n\",\n",
    "    \"    on=\\\"证券代码\\\",\\n\",\n",
    "    \"    how=\\\"anti\\\",\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 52,\n",
    "   \"id\": \"f4da212e-f2ca-4f22-a1db-b692c671b5c8\",\n",
    "   \"metadata\": {\n",
    "    \"jupyter\": {\n",
    "     \"source_hidden\": true\n",
    "    },\n",
    "    \"scrolled\": true\n",
    "   },\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (358, 18)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>1</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:33:37&quot;</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>4.05</td><td>34400.0</td><td>139320.0</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>-139342.29</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>2</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:34:24&quot;</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>3.65</td><td>38300.0</td><td>139795.0</td><td>22.37</td><td>0.0</td><td>1.38</td><td>0.0</td><td>-139818.75</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>3</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:36:30&quot;</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>6.54</td><td>21400.0</td><td>139956.0</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-139979.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>4</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:37:25&quot;</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>2.59</td><td>54000.0</td><td>139860.0</td><td>22.38</td><td>0.0</td><td>1.42</td><td>0.0</td><td>-139883.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>5</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:38:16&quot;</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>13.51</td><td>10400.0</td><td>140504.0</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-140526.48</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>359</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:31:53&quot;</td><td>&quot;002956&quot;</td><td>&quot;西麦食品&quot;</td><td>&quot;卖出&quot;</td><td>14.13</td><td>5000.0</td><td>70650.0</td><td>6.74</td><td>35.35</td><td>0.0</td><td>0.0</td><td>70607.91</td><td>0.000095</td><td>0.0005</td><td>0.0</td></tr><tr><td>360</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:39:57&quot;</td><td>&quot;603214&quot;</td><td>&quot;爱婴室&quot;</td><td>&quot;买入&quot;</td><td>15.84</td><td>3100.0</td><td>49104.0</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>-49109.51</td><td>0.000102</td><td>0.0</td><td>0.00001</td></tr><tr><td>361</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:40:55&quot;</td><td>&quot;300132&quot;</td><td>&quot;青松股份&quot;</td><td>&quot;买入&quot;</td><td>5.21</td><td>9600.0</td><td>50016.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-50021.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr><tr><td>362</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:43:13&quot;</td><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>&quot;买入&quot;</td><td>5.91</td><td>8400.0</td><td>49644.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49649.0</td><td>0.000101</td><td>0.0</td><td>0.0</td></tr><tr><td>363</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:44:45&quot;</td><td>&quot;002111&quot;</td><td>&quot;威海广泰&quot;</td><td>&quot;买入&quot;</td><td>9.24</td><td>5400.0</td><td>49896.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49901.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (358, 18)\\n\",\n",
    "       \"┌──────┬─────────┬─────────┬─────────┬───┬─────────┬─────────┬────────┬────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商    ┆ 交易日  ┆ 交易时  ┆ … ┆ 发生金  ┆ 手续费  ┆ 印花税 ┆ 过户费 │\\n\",\n",
    "       \"│ ---  ┆ ---     ┆ 期      ┆ 间      ┆   ┆ 额      ┆ 率      ┆ 率     ┆ 率     │\\n\",\n",
    "       \"│ u32  ┆ str     ┆ ---     ┆ ---     ┆   ┆ ---     ┆ ---     ┆ ---    ┆ ---    │\\n\",\n",
    "       \"│      ┆         ┆ date    ┆ str     ┆   ┆ f64     ┆ f64     ┆ f64    ┆ f64    │\\n\",\n",
    "       \"╞══════╪═════════╪═════════╪═════════╪═══╪═════════╪═════════╪════════╪════════╡\\n\",\n",
    "       \"│ 1    ┆ 湘财    ┆ 2022-07 ┆ 09:33:3 ┆ … ┆ -139342 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 7       ┆   ┆ .29     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 2    ┆ 湘财    ┆ 2022-07 ┆ 09:34:2 ┆ … ┆ -139818 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 4       ┆   ┆ .75     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 3    ┆ 湘财    ┆ 2022-07 ┆ 09:36:3 ┆ … ┆ -139979 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 0       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 4    ┆ 湘财    ┆ 2022-07 ┆ 09:37:2 ┆ … ┆ -139883 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 5       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 5    ┆ 湘财    ┆ 2022-07 ┆ 09:38:1 ┆ … ┆ -140526 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 6       ┆   ┆ .48     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ …    ┆ …       ┆ …       ┆ …       ┆ … ┆ …       ┆ …       ┆ …      ┆ …      │\\n\",\n",
    "       \"│ 359  ┆ 海通两  ┆ 2023-10 ┆ 09:31:5 ┆ … ┆ 70607.9 ┆ 0.00009 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 1       ┆ 5       ┆        ┆        │\\n\",\n",
    "       \"│ 360  ┆ 海通两  ┆ 2023-10 ┆ 09:39:5 ┆ … ┆ -49109. ┆ 0.00010 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 7       ┆   ┆ 51      ┆ 2       ┆        ┆ 1      │\\n\",\n",
    "       \"│ 361  ┆ 海通两  ┆ 2023-10 ┆ 09:40:5 ┆ … ┆ -50021. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 362  ┆ 海通两  ┆ 2023-10 ┆ 09:43:1 ┆ … ┆ -49649. ┆ 0.00010 ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 0       ┆ 1       ┆        ┆        │\\n\",\n",
    "       \"│ 363  ┆ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ … ┆ -49901. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"└──────┴─────────┴─────────┴─────────┴───┴─────────┴─────────┴────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 52,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d1\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 67,\n",
    "   \"id\": \"c2dbc7c8-e99f-41dc-b10d-0f152265fb2e\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"datetime.date(2022, 7, 11)\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 67,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"start_date = df[\\\"交易日期\\\"].min()\\n\",\n",
    "    \"start_date\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 69,\n",
    "   \"id\": \"54949829-827b-4441-bd59-083b03867fea\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"datetime.date(2023, 10, 31)\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 69,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"end_date = df[\\\"交易日期\\\"].max()\\n\",\n",
    "    \"end_date\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 71,\n",
    "   \"id\": \"7e55bd6e-730d-4f18-9d9b-7045ddce076c\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (478, 1)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>交易日期</th></tr><tr><td>date</td></tr></thead><tbody><tr><td>2022-07-11</td></tr><tr><td>2022-07-12</td></tr><tr><td>2022-07-13</td></tr><tr><td>2022-07-14</td></tr><tr><td>2022-07-15</td></tr><tr><td>&hellip;</td></tr><tr><td>2023-10-27</td></tr><tr><td>2023-10-28</td></tr><tr><td>2023-10-29</td></tr><tr><td>2023-10-30</td></tr><tr><td>2023-10-31</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (478, 1)\\n\",\n",
    "       \"┌────────────┐\\n\",\n",
    "       \"│ 交易日期   │\\n\",\n",
    "       \"│ ---        │\\n\",\n",
    "       \"│ date       │\\n\",\n",
    "       \"╞════════════╡\\n\",\n",
    "       \"│ 2022-07-11 │\\n\",\n",
    "       \"│ 2022-07-12 │\\n\",\n",
    "       \"│ 2022-07-13 │\\n\",\n",
    "       \"│ 2022-07-14 │\\n\",\n",
    "       \"│ 2022-07-15 │\\n\",\n",
    "       \"│ …          │\\n\",\n",
    "       \"│ 2023-10-27 │\\n\",\n",
    "       \"│ 2023-10-28 │\\n\",\n",
    "       \"│ 2023-10-29 │\\n\",\n",
    "       \"│ 2023-10-30 │\\n\",\n",
    "       \"│ 2023-10-31 │\\n\",\n",
    "       \"└────────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 71,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"k1 = pl.select(交易日期=pl.date_range(start_date, end_date))\\n\",\n",
    "    \"k1\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 76,\n",
    "   \"id\": \"4c164354-30fd-4888-8193-bb5e2b04a2dc\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (152, 1)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>证券代码</th></tr><tr><td>str</td></tr></thead><tbody><tr><td>&quot;000096&quot;</td></tr><tr><td>&quot;000532&quot;</td></tr><tr><td>&quot;000559&quot;</td></tr><tr><td>&quot;000599&quot;</td></tr><tr><td>&quot;000655&quot;</td></tr><tr><td>&hellip;</td></tr><tr><td>&quot;688299&quot;</td></tr><tr><td>&quot;688321&quot;</td></tr><tr><td>&quot;688360&quot;</td></tr><tr><td>&quot;688393&quot;</td></tr><tr><td>&quot;688660&quot;</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (152, 1)\\n\",\n",
    "       \"┌──────────┐\\n\",\n",
    "       \"│ 证券代码 │\\n\",\n",
    "       \"│ ---      │\\n\",\n",
    "       \"│ str      │\\n\",\n",
    "       \"╞══════════╡\\n\",\n",
    "       \"│ 000096   │\\n\",\n",
    "       \"│ 000532   │\\n\",\n",
    "       \"│ 000559   │\\n\",\n",
    "       \"│ 000599   │\\n\",\n",
    "       \"│ 000655   │\\n\",\n",
    "       \"│ …        │\\n\",\n",
    "       \"│ 688299   │\\n\",\n",
    "       \"│ 688321   │\\n\",\n",
    "       \"│ 688360   │\\n\",\n",
    "       \"│ 688393   │\\n\",\n",
    "       \"│ 688660   │\\n\",\n",
    "       \"└──────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 76,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"k2 = df[\\\"证券代码\\\"].unique().sort().to_frame()\\n\",\n",
    "    \"k2\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 64,\n",
    "   \"id\": \"565780a0-639f-48f3-b090-4be9ae3a7f4e\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (2, 1)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>date</th></tr><tr><td>i64</td></tr></thead><tbody><tr><td>1</td></tr><tr><td>2</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (2, 1)\\n\",\n",
    "       \"┌──────┐\\n\",\n",
    "       \"│ date │\\n\",\n",
    "       \"│ ---  │\\n\",\n",
    "       \"│ i64  │\\n\",\n",
    "       \"╞══════╡\\n\",\n",
    "       \"│ 1    │\\n\",\n",
    "       \"│ 2    │\\n\",\n",
    "       \"└──────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 64,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"k1 = pl.DataFrame({\\\"date\\\": [1, 2]})\\n\",\n",
    "    \"k1\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 58,\n",
    "   \"id\": \"fbffd2e7-7e21-4716-9725-f2a9dd783e7b\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (3, 1)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>name</th></tr><tr><td>str</td></tr></thead><tbody><tr><td>&quot;A&quot;</td></tr><tr><td>&quot;B&quot;</td></tr><tr><td>&quot;C&quot;</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (3, 1)\\n\",\n",
    "       \"┌──────┐\\n\",\n",
    "       \"│ name │\\n\",\n",
    "       \"│ ---  │\\n\",\n",
    "       \"│ str  │\\n\",\n",
    "       \"╞══════╡\\n\",\n",
    "       \"│ A    │\\n\",\n",
    "       \"│ B    │\\n\",\n",
    "       \"│ C    │\\n\",\n",
    "       \"└──────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 58,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"k2 = pl.DataFrame({\\\"name\\\": [\\\"A\\\", \\\"B\\\", \\\"C\\\"]})\\n\",\n",
    "    \"k2\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 78,\n",
    "   \"id\": \"8a1cd0ad-ddc3-48d1-8185-1b975f8644a9\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"k = k1.join(k2, how=\\\"cross\\\")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 102,\n",
    "   \"id\": \"f110fd1b-66ce-4cc1-a7ef-15f45143fbad\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"d2 = (\\n\",\n",
    "    \"    k.join(\\n\",\n",
    "    \"        d1,\\n\",\n",
    "    \"        left_on=[\\\"交易日期\\\", \\\"证券代码\\\"],\\n\",\n",
    "    \"        right_on=[\\\"交易日期\\\", \\\"证券代码\\\"],\\n\",\n",
    "    \"        how=\\\"left\\\",\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .sort(\\\"交易日期\\\", \\\"证券代码\\\")\\n\",\n",
    "    \"    .with_columns(\\n\",\n",
    "    \"        结余数量=(\\n\",\n",
    "    \"            pl.when(pl.col(\\\"买卖标志\\\") == \\\"卖出\\\")\\n\",\n",
    "    \"            .then(-pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .when(pl.col(\\\"买卖标志\\\") == \\\"买入\\\")\\n\",\n",
    "    \"            .then(pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .otherwise(0)\\n\",\n",
    "    \"            .cum_sum()\\n\",\n",
    "    \"            .over(\\\"证券代码\\\")\\n\",\n",
    "    \"        ),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .filter(pl.col.结余数量 > 0)\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 92,\n",
    "   \"id\": \"6f06155f-8474-4ac7-bb82-92afe4d6050f\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (7, 2)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>n</th><th>running_n</th></tr><tr><td>i64</td><td>i64</td></tr></thead><tbody><tr><td>500</td><td>500</td></tr><tr><td>0</td><td>500</td></tr><tr><td>0</td><td>500</td></tr><tr><td>-200</td><td>300</td></tr><tr><td>300</td><td>600</td></tr><tr><td>0</td><td>600</td></tr><tr><td>-400</td><td>200</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (7, 2)\\n\",\n",
    "       \"┌──────┬───────────┐\\n\",\n",
    "       \"│ n    ┆ running_n │\\n\",\n",
    "       \"│ ---  ┆ ---       │\\n\",\n",
    "       \"│ i64  ┆ i64       │\\n\",\n",
    "       \"╞══════╪═══════════╡\\n\",\n",
    "       \"│ 500  ┆ 500       │\\n\",\n",
    "       \"│ 0    ┆ 500       │\\n\",\n",
    "       \"│ 0    ┆ 500       │\\n\",\n",
    "       \"│ -200 ┆ 300       │\\n\",\n",
    "       \"│ 300  ┆ 600       │\\n\",\n",
    "       \"│ 0    ┆ 600       │\\n\",\n",
    "       \"│ -400 ┆ 200       │\\n\",\n",
    "       \"└──────┴───────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 92,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d = pl.DataFrame({\\\"n\\\": [500, 0, 0, -200, 300, 0, -400]})\\n\",\n",
    "    \"d.with_columns(running_n=pl.col.n.cum_sum())\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 98,\n",
    "   \"id\": \"90db4878-2441-498c-8c15-684dde5c91e2\",\n",
    "   \"metadata\": {\n",
    "    \"scrolled\": true\n",
    "   },\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (10, 3)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>n</th><th>name</th><th>runing_n</th></tr><tr><td>i64</td><td>str</td><td>i64</td></tr></thead><tbody><tr><td>500</td><td>&quot;A&quot;</td><td>500</td></tr><tr><td>0</td><td>&quot;A&quot;</td><td>500</td></tr><tr><td>-200</td><td>&quot;A&quot;</td><td>300</td></tr><tr><td>300</td><td>&quot;A&quot;</td><td>600</td></tr><tr><td>-400</td><td>&quot;A&quot;</td><td>200</td></tr><tr><td>800</td><td>&quot;B&quot;</td><td>800</td></tr><tr><td>300</td><td>&quot;B&quot;</td><td>1100</td></tr><tr><td>-200</td><td>&quot;B&quot;</td><td>900</td></tr><tr><td>100</td><td>&quot;B&quot;</td><td>1000</td></tr><tr><td>-400</td><td>&quot;B&quot;</td><td>600</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (10, 3)\\n\",\n",
    "       \"┌──────┬──────┬──────────┐\\n\",\n",
    "       \"│ n    ┆ name ┆ runing_n │\\n\",\n",
    "       \"│ ---  ┆ ---  ┆ ---      │\\n\",\n",
    "       \"│ i64  ┆ str  ┆ i64      │\\n\",\n",
    "       \"╞══════╪══════╪══════════╡\\n\",\n",
    "       \"│ 500  ┆ A    ┆ 500      │\\n\",\n",
    "       \"│ 0    ┆ A    ┆ 500      │\\n\",\n",
    "       \"│ -200 ┆ A    ┆ 300      │\\n\",\n",
    "       \"│ 300  ┆ A    ┆ 600      │\\n\",\n",
    "       \"│ -400 ┆ A    ┆ 200      │\\n\",\n",
    "       \"│ 800  ┆ B    ┆ 800      │\\n\",\n",
    "       \"│ 300  ┆ B    ┆ 1100     │\\n\",\n",
    "       \"│ -200 ┆ B    ┆ 900      │\\n\",\n",
    "       \"│ 100  ┆ B    ┆ 1000     │\\n\",\n",
    "       \"│ -400 ┆ B    ┆ 600      │\\n\",\n",
    "       \"└──────┴──────┴──────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 98,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"dd1 = pl.DataFrame({\\\"n\\\": [500, 0, -200, 300, -400]}).with_columns(name=pl.lit(\\\"A\\\"))\\n\",\n",
    "    \"dd2 = pl.DataFrame({\\\"n\\\": [800, 300, -200, 100, -400]}).with_columns(name=pl.lit(\\\"B\\\"))\\n\",\n",
    "    \"dd = pl.concat([dd1, dd2])\\n\",\n",
    "    \"dd.with_columns(\\n\",\n",
    "    \"    runing_n=pl.col.n.cum_sum().over(\\\"name\\\"),\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 103,\n",
    "   \"id\": \"c154da11-2aa6-443f-8b3c-0753ffa374d1\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"application/vnd.jupyter.widget-view+json\": {\n",
    "       \"model_id\": \"4a66af832e614c5492b158174445b63a\",\n",
    "       \"version_major\": 2,\n",
    "       \"version_minor\": 0\n",
    "      },\n",
    "      \"text/plain\": [\n",
    "       \"PerspectiveWidget(binding_mode='server', columns=['交易日期', '证券代码', '序号', '券商', '交易时间', '证券名称', '买卖标志', '成交价格', …\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 103,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"PerspectiveWidget(d2)\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 4,\n",
    "   \"id\": \"d3c2bf07-0ca3-428a-9288-315112bb5249\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"import polars as pl\\n\",\n",
    "    \"from perspective.widget import PerspectiveWidget\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 5,\n",
    "   \"id\": \"d75103f9-718b-46ed-9ecb-ec855e96f821\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (363, 18)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>1</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:33:37&quot;</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>4.05</td><td>34400.0</td><td>139320.0</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>-139342.29</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>2</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:34:24&quot;</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>3.65</td><td>38300.0</td><td>139795.0</td><td>22.37</td><td>0.0</td><td>1.38</td><td>0.0</td><td>-139818.75</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>3</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:36:30&quot;</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>6.54</td><td>21400.0</td><td>139956.0</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-139979.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>4</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:37:25&quot;</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>2.59</td><td>54000.0</td><td>139860.0</td><td>22.38</td><td>0.0</td><td>1.42</td><td>0.0</td><td>-139883.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>5</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:38:16&quot;</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>13.51</td><td>10400.0</td><td>140504.0</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-140526.48</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>359</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:31:53&quot;</td><td>&quot;002956&quot;</td><td>&quot;西麦食品&quot;</td><td>&quot;卖出&quot;</td><td>14.13</td><td>5000.0</td><td>70650.0</td><td>6.74</td><td>35.35</td><td>0.0</td><td>0.0</td><td>70607.91</td><td>0.000095</td><td>0.0005</td><td>0.0</td></tr><tr><td>360</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:39:57&quot;</td><td>&quot;603214&quot;</td><td>&quot;爱婴室&quot;</td><td>&quot;买入&quot;</td><td>15.84</td><td>3100.0</td><td>49104.0</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>-49109.51</td><td>0.000102</td><td>0.0</td><td>0.00001</td></tr><tr><td>361</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:40:55&quot;</td><td>&quot;300132&quot;</td><td>&quot;青松股份&quot;</td><td>&quot;买入&quot;</td><td>5.21</td><td>9600.0</td><td>50016.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-50021.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr><tr><td>362</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:43:13&quot;</td><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>&quot;买入&quot;</td><td>5.91</td><td>8400.0</td><td>49644.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49649.0</td><td>0.000101</td><td>0.0</td><td>0.0</td></tr><tr><td>363</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:44:45&quot;</td><td>&quot;002111&quot;</td><td>&quot;威海广泰&quot;</td><td>&quot;买入&quot;</td><td>9.24</td><td>5400.0</td><td>49896.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49901.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (363, 18)\\n\",\n",
    "       \"┌──────┬─────────┬─────────┬─────────┬───┬─────────┬─────────┬────────┬────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商    ┆ 交易日  ┆ 交易时  ┆ … ┆ 发生金  ┆ 手续费  ┆ 印花税 ┆ 过户费 │\\n\",\n",
    "       \"│ ---  ┆ ---     ┆ 期      ┆ 间      ┆   ┆ 额      ┆ 率      ┆ 率     ┆ 率     │\\n\",\n",
    "       \"│ u32  ┆ str     ┆ ---     ┆ ---     ┆   ┆ ---     ┆ ---     ┆ ---    ┆ ---    │\\n\",\n",
    "       \"│      ┆         ┆ date    ┆ str     ┆   ┆ f64     ┆ f64     ┆ f64    ┆ f64    │\\n\",\n",
    "       \"╞══════╪═════════╪═════════╪═════════╪═══╪═════════╪═════════╪════════╪════════╡\\n\",\n",
    "       \"│ 1    ┆ 湘财    ┆ 2022-07 ┆ 09:33:3 ┆ … ┆ -139342 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 7       ┆   ┆ .29     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 2    ┆ 湘财    ┆ 2022-07 ┆ 09:34:2 ┆ … ┆ -139818 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 4       ┆   ┆ .75     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 3    ┆ 湘财    ┆ 2022-07 ┆ 09:36:3 ┆ … ┆ -139979 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 0       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 4    ┆ 湘财    ┆ 2022-07 ┆ 09:37:2 ┆ … ┆ -139883 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 5       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 5    ┆ 湘财    ┆ 2022-07 ┆ 09:38:1 ┆ … ┆ -140526 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 6       ┆   ┆ .48     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ …    ┆ …       ┆ …       ┆ …       ┆ … ┆ …       ┆ …       ┆ …      ┆ …      │\\n\",\n",
    "       \"│ 359  ┆ 海通两  ┆ 2023-10 ┆ 09:31:5 ┆ … ┆ 70607.9 ┆ 0.00009 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 1       ┆ 5       ┆        ┆        │\\n\",\n",
    "       \"│ 360  ┆ 海通两  ┆ 2023-10 ┆ 09:39:5 ┆ … ┆ -49109. ┆ 0.00010 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 7       ┆   ┆ 51      ┆ 2       ┆        ┆ 1      │\\n\",\n",
    "       \"│ 361  ┆ 海通两  ┆ 2023-10 ┆ 09:40:5 ┆ … ┆ -50021. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 362  ┆ 海通两  ┆ 2023-10 ┆ 09:43:1 ┆ … ┆ -49649. ┆ 0.00010 ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 0       ┆ 1       ┆        ┆        │\\n\",\n",
    "       \"│ 363  ┆ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ … ┆ -49901. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"└──────┴─────────┴─────────┴─────────┴───┴─────────┴─────────┴────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 5,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"df = pl.read_parquet(\\\"stock_trades.parquet\\\")\\n\",\n",
    "    \"df = df.sort(\\\"交易日期\\\", \\\"交易时间\\\", \\\"证券代码\\\")\\n\",\n",
    "    \"df = df.with_columns(\\n\",\n",
    "    \"    pl.col(\\\"交易时间\\\").cast(pl.String),\\n\",\n",
    "    \"    手续费率=pl.col(\\\"手续费\\\") / pl.col(\\\"成交金额\\\"),\\n\",\n",
    "    \"    印花税率=pl.col(\\\"印花税\\\") / pl.col(\\\"成交金额\\\"),\\n\",\n",
    "    \"    过户费率=pl.col(\\\"过户费\\\") / pl.col(\\\"成交金额\\\"),\\n\",\n",
    "    \")\\n\",\n",
    "    \"\\n\",\n",
    "    \"df = df.with_row_index(\\\"序号\\\", 1)\\n\",\n",
    "    \"df\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 6,\n",
    "   \"id\": \"27bab867-6011-4fd6-8182-b71d6043f63c\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (2, 2)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>券商</th><th>count</th></tr><tr><td>str</td><td>u32</td></tr></thead><tbody><tr><td>&quot;湘财&quot;</td><td>19</td></tr><tr><td>&quot;海通普通&quot;</td><td>33</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (2, 2)\\n\",\n",
    "       \"┌──────────┬───────┐\\n\",\n",
    "       \"│ 券商     ┆ count │\\n\",\n",
    "       \"│ ---      ┆ ---   │\\n\",\n",
    "       \"│ str      ┆ u32   │\\n\",\n",
    "       \"╞══════════╪═══════╡\\n\",\n",
    "       \"│ 湘财     ┆ 19    │\\n\",\n",
    "       \"│ 海通普通 ┆ 33    │\\n\",\n",
    "       \"└──────────┴───────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 6,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"df.filter(pl.col(\\\"手续费\\\") < 5)[\\\"券商\\\"].value_counts()\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 7,\n",
    "   \"id\": \"f9ff5691-88b5-44cb-98cb-420c3d8b8d72\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (53, 18)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>320</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;09:34:39&quot;</td><td>&quot;300642&quot;</td><td>&quot;透景生命&quot;</td><td>&quot;卖出&quot;</td><td>18.106</td><td>2500.0</td><td>45266.0</td><td>5.0</td><td>45.26</td><td>0.0</td><td>0.0</td><td>45215.74</td><td>0.00011</td><td>0.001</td><td>0.0</td></tr><tr><td>323</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;09:39:25&quot;</td><td>&quot;600333&quot;</td><td>&quot;长春燃气&quot;</td><td>&quot;卖出&quot;</td><td>5.04</td><td>3900.0</td><td>19656.0</td><td>5.0</td><td>19.64</td><td>0.23</td><td>0.0</td><td>19631.13</td><td>0.000254</td><td>0.000999</td><td>0.000012</td></tr><tr><td>325</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;10:03:59&quot;</td><td>&quot;600525&quot;</td><td>&quot;长园集团&quot;</td><td>&quot;买入&quot;</td><td>4.88</td><td>8500.0</td><td>41480.0</td><td>5.0</td><td>0.0</td><td>0.35</td><td>0.0</td><td>-41485.35</td><td>0.000121</td><td>0.0</td><td>0.000008</td></tr><tr><td>327</td><td>&quot;海通两融&quot;</td><td>2023-09-01</td><td>&quot;10:22:36&quot;</td><td>&quot;300889&quot;</td><td>&quot;爱克股份&quot;</td><td>&quot;卖出&quot;</td><td>15.22</td><td>1500.0</td><td>22830.0</td><td>5.0</td><td>11.42</td><td>0.0</td><td>0.0</td><td>22813.58</td><td>0.000219</td><td>0.0005</td><td>0.0</td></tr><tr><td>329</td><td>&quot;海通两融&quot;</td><td>2023-09-01</td><td>&quot;10:23:28&quot;</td><td>&quot;300889&quot;</td><td>&quot;爱克股份&quot;</td><td>&quot;卖出&quot;</td><td>15.21</td><td>1700.0</td><td>25857.0</td><td>5.0</td><td>12.92</td><td>0.0</td><td>0.0</td><td>25839.08</td><td>0.000193</td><td>0.0005</td><td>0.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>322</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;09:36:13&quot;</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;卖出&quot;</td><td>9.36</td><td>10600.0</td><td>99216.0</td><td>10.91</td><td>99.24</td><td>1.0</td><td>0.0</td><td>99104.85</td><td>0.00011</td><td>0.001</td><td>0.00001</td></tr><tr><td>319</td><td>&quot;海通两融&quot;</td><td>2023-08-09</td><td>&quot;10:12:16&quot;</td><td>&quot;600336&quot;</td><td>&quot;澳柯玛&quot;</td><td>&quot;买入&quot;</td><td>5.72</td><td>17400.0</td><td>99528.0</td><td>10.95</td><td>0.0</td><td>1.0</td><td>0.0</td><td>-99539.95</td><td>0.00011</td><td>0.0</td><td>0.00001</td></tr><tr><td>324</td><td>&quot;海通两融&quot;</td><td>2023-08-22</td><td>&quot;09:58:46&quot;</td><td>&quot;603626&quot;</td><td>&quot;科森科技&quot;</td><td>&quot;买入&quot;</td><td>6.35</td><td>15700.0</td><td>99695.0</td><td>10.97</td><td>0.0</td><td>1.02</td><td>0.0</td><td>-99706.99</td><td>0.00011</td><td>0.0</td><td>0.00001</td></tr><tr><td>316</td><td>&quot;海通两融&quot;</td><td>2023-08-04</td><td>&quot;10:07:37&quot;</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;买入&quot;</td><td>9.43</td><td>10600.0</td><td>99958.0</td><td>11.0</td><td>0.0</td><td>1.01</td><td>0.0</td><td>-99970.01</td><td>0.00011</td><td>0.0</td><td>0.00001</td></tr><tr><td>340</td><td>&quot;海通两融&quot;</td><td>2023-09-12</td><td>&quot;14:31:39&quot;</td><td>&quot;603626&quot;</td><td>&quot;科森科技&quot;</td><td>&quot;卖出&quot;</td><td>7.43</td><td>15700.0</td><td>116651.0</td><td>11.13</td><td>58.32</td><td>1.17</td><td>0.0</td><td>116580.38</td><td>0.000095</td><td>0.0005</td><td>0.00001</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (53, 18)\\n\",\n",
    "       \"┌──────┬─────────┬─────────┬─────────┬───┬─────────┬─────────┬────────┬────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商    ┆ 交易日  ┆ 交易时  ┆ … ┆ 发生金  ┆ 手续费  ┆ 印花税 ┆ 过户费 │\\n\",\n",
    "       \"│ ---  ┆ ---     ┆ 期      ┆ 间      ┆   ┆ 额      ┆ 率      ┆ 率     ┆ 率     │\\n\",\n",
    "       \"│ u32  ┆ str     ┆ ---     ┆ ---     ┆   ┆ ---     ┆ ---     ┆ ---    ┆ ---    │\\n\",\n",
    "       \"│      ┆         ┆ date    ┆ str     ┆   ┆ f64     ┆ f64     ┆ f64    ┆ f64    │\\n\",\n",
    "       \"╞══════╪═════════╪═════════╪═════════╪═══╪═════════╪═════════╪════════╪════════╡\\n\",\n",
    "       \"│ 320  ┆ 海通两  ┆ 2023-08 ┆ 09:34:3 ┆ … ┆ 45215.7 ┆ 0.00011 ┆ 0.001  ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 9       ┆   ┆ 4       ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 323  ┆ 海通两  ┆ 2023-08 ┆ 09:39:2 ┆ … ┆ 19631.1 ┆ 0.00025 ┆ 0.0009 ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 5       ┆   ┆ 3       ┆ 4       ┆ 99     ┆ 12     │\\n\",\n",
    "       \"│ 325  ┆ 海通两  ┆ 2023-08 ┆ 10:03:5 ┆ … ┆ -41485. ┆ 0.00012 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 9       ┆   ┆ 35      ┆ 1       ┆        ┆ 08     │\\n\",\n",
    "       \"│ 327  ┆ 海通两  ┆ 2023-09 ┆ 10:22:3 ┆ … ┆ 22813.5 ┆ 0.00021 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -01     ┆ 6       ┆   ┆ 8       ┆ 9       ┆        ┆        │\\n\",\n",
    "       \"│ 329  ┆ 海通两  ┆ 2023-09 ┆ 10:23:2 ┆ … ┆ 25839.0 ┆ 0.00019 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -01     ┆ 8       ┆   ┆ 8       ┆ 3       ┆        ┆        │\\n\",\n",
    "       \"│ …    ┆ …       ┆ …       ┆ …       ┆ … ┆ …       ┆ …       ┆ …      ┆ …      │\\n\",\n",
    "       \"│ 322  ┆ 海通两  ┆ 2023-08 ┆ 09:36:1 ┆ … ┆ 99104.8 ┆ 0.00011 ┆ 0.001  ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 3       ┆   ┆ 5       ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 319  ┆ 海通两  ┆ 2023-08 ┆ 10:12:1 ┆ … ┆ -99539. ┆ 0.00011 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -09     ┆ 6       ┆   ┆ 95      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 324  ┆ 海通两  ┆ 2023-08 ┆ 09:58:4 ┆ … ┆ -99706. ┆ 0.00011 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -22     ┆ 6       ┆   ┆ 99      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 316  ┆ 海通两  ┆ 2023-08 ┆ 10:07:3 ┆ … ┆ -99970. ┆ 0.00011 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -04     ┆ 7       ┆   ┆ 01      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 340  ┆ 海通两  ┆ 2023-09 ┆ 14:31:3 ┆ … ┆ 116580. ┆ 0.00009 ┆ 0.0005 ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -12     ┆ 9       ┆   ┆ 38      ┆ 5       ┆        ┆ 1      │\\n\",\n",
    "       \"└──────┴─────────┴─────────┴─────────┴───┴─────────┴─────────┴────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 7,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"df.filter(pl.col(\\\"券商\\\") == \\\"海通两融\\\").sort(\\\"手续费\\\")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 8,\n",
    "   \"id\": \"bb086939-deb4-48bb-a928-38de3c48eba7\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"d1 = df.join(\\n\",\n",
    "    \"    df.group_by(\\\"证券代码\\\", \\\"证券名称\\\")\\n\",\n",
    "    \"    .agg(\\n\",\n",
    "    \"        结余数量=(\\n\",\n",
    "    \"            pl.when(pl.col(\\\"买卖标志\\\") == \\\"卖出\\\")\\n\",\n",
    "    \"            .then(-pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .when(pl.col(\\\"买卖标志\\\") == \\\"买入\\\")\\n\",\n",
    "    \"            .then(pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .sum()\\n\",\n",
    "    \"        ),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .filter(pl.col(\\\"结余数量\\\") < 0),\\n\",\n",
    "    \"    on=\\\"证券代码\\\",\\n\",\n",
    "    \"    how=\\\"anti\\\",\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 9,\n",
    "   \"id\": \"1905db0d-a1fb-42ed-9cba-41d1367dba38\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"datetime.date(2022, 7, 11)\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 9,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"start_date = df[\\\"交易日期\\\"].min()\\n\",\n",
    "    \"start_date\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 10,\n",
    "   \"id\": \"a5cdac4b-f9df-4c22-a925-fceee69c3c89\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"datetime.date(2023, 10, 31)\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 10,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"end_date = df[\\\"交易日期\\\"].max()\\n\",\n",
    "    \"end_date\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 11,\n",
    "   \"id\": \"4f1cce40-5a05-4be1-821f-56f88909d2cc\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (478, 1)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>交易日期</th></tr><tr><td>date</td></tr></thead><tbody><tr><td>2022-07-11</td></tr><tr><td>2022-07-12</td></tr><tr><td>2022-07-13</td></tr><tr><td>2022-07-14</td></tr><tr><td>2022-07-15</td></tr><tr><td>&hellip;</td></tr><tr><td>2023-10-27</td></tr><tr><td>2023-10-28</td></tr><tr><td>2023-10-29</td></tr><tr><td>2023-10-30</td></tr><tr><td>2023-10-31</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (478, 1)\\n\",\n",
    "       \"┌────────────┐\\n\",\n",
    "       \"│ 交易日期   │\\n\",\n",
    "       \"│ ---        │\\n\",\n",
    "       \"│ date       │\\n\",\n",
    "       \"╞════════════╡\\n\",\n",
    "       \"│ 2022-07-11 │\\n\",\n",
    "       \"│ 2022-07-12 │\\n\",\n",
    "       \"│ 2022-07-13 │\\n\",\n",
    "       \"│ 2022-07-14 │\\n\",\n",
    "       \"│ 2022-07-15 │\\n\",\n",
    "       \"│ …          │\\n\",\n",
    "       \"│ 2023-10-27 │\\n\",\n",
    "       \"│ 2023-10-28 │\\n\",\n",
    "       \"│ 2023-10-29 │\\n\",\n",
    "       \"│ 2023-10-30 │\\n\",\n",
    "       \"│ 2023-10-31 │\\n\",\n",
    "       \"└────────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 11,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"k1 = pl.select(交易日期=pl.date_range(start_date, end_date))\\n\",\n",
    "    \"k1\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 12,\n",
    "   \"id\": \"eeeaab6d-6a7a-499a-8396-15847dc781ec\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (152, 1)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>证券代码</th></tr><tr><td>str</td></tr></thead><tbody><tr><td>&quot;000096&quot;</td></tr><tr><td>&quot;000532&quot;</td></tr><tr><td>&quot;000559&quot;</td></tr><tr><td>&quot;000599&quot;</td></tr><tr><td>&quot;000655&quot;</td></tr><tr><td>&hellip;</td></tr><tr><td>&quot;688299&quot;</td></tr><tr><td>&quot;688321&quot;</td></tr><tr><td>&quot;688360&quot;</td></tr><tr><td>&quot;688393&quot;</td></tr><tr><td>&quot;688660&quot;</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (152, 1)\\n\",\n",
    "       \"┌──────────┐\\n\",\n",
    "       \"│ 证券代码 │\\n\",\n",
    "       \"│ ---      │\\n\",\n",
    "       \"│ str      │\\n\",\n",
    "       \"╞══════════╡\\n\",\n",
    "       \"│ 000096   │\\n\",\n",
    "       \"│ 000532   │\\n\",\n",
    "       \"│ 000559   │\\n\",\n",
    "       \"│ 000599   │\\n\",\n",
    "       \"│ 000655   │\\n\",\n",
    "       \"│ …        │\\n\",\n",
    "       \"│ 688299   │\\n\",\n",
    "       \"│ 688321   │\\n\",\n",
    "       \"│ 688360   │\\n\",\n",
    "       \"│ 688393   │\\n\",\n",
    "       \"│ 688660   │\\n\",\n",
    "       \"└──────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 12,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"k2 = df[\\\"证券代码\\\"].unique().sort().to_frame()\\n\",\n",
    "    \"k2\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 13,\n",
    "   \"id\": \"4736980b-a90e-49ce-a04d-b0008d25f8fb\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"k = k1.join(k2, how=\\\"cross\\\")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 14,\n",
    "   \"id\": \"556e1bdb-61f3-47c4-a0c0-1c1c2ed1ce8f\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"d2 = (\\n\",\n",
    "    \"    k.join(\\n\",\n",
    "    \"        d1,\\n\",\n",
    "    \"        left_on=[\\\"交易日期\\\", \\\"证券代码\\\"],\\n\",\n",
    "    \"        right_on=[\\\"交易日期\\\", \\\"证券代码\\\"],\\n\",\n",
    "    \"        how=\\\"left\\\",\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .sort(\\\"交易日期\\\", \\\"证券代码\\\")\\n\",\n",
    "    \"    .with_columns(\\n\",\n",
    "    \"        结余数量=(\\n\",\n",
    "    \"            pl.when(pl.col(\\\"买卖标志\\\") == \\\"卖出\\\")\\n\",\n",
    "    \"            .then(-pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .when(pl.col(\\\"买卖标志\\\") == \\\"买入\\\")\\n\",\n",
    "    \"            .then(pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .otherwise(0)\\n\",\n",
    "    \"            .cum_sum()\\n\",\n",
    "    \"            .over(\\\"证券代码\\\")\\n\",\n",
    "    \"        ),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .filter(pl.col.结余数量 > 0)\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 15,\n",
    "   \"id\": \"d817b1a2-ed48-436a-96bb-5c819316cf16\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (7, 2)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>n</th><th>running_n</th></tr><tr><td>i64</td><td>i64</td></tr></thead><tbody><tr><td>500</td><td>500</td></tr><tr><td>0</td><td>500</td></tr><tr><td>0</td><td>500</td></tr><tr><td>-200</td><td>300</td></tr><tr><td>300</td><td>600</td></tr><tr><td>0</td><td>600</td></tr><tr><td>-400</td><td>200</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (7, 2)\\n\",\n",
    "       \"┌──────┬───────────┐\\n\",\n",
    "       \"│ n    ┆ running_n │\\n\",\n",
    "       \"│ ---  ┆ ---       │\\n\",\n",
    "       \"│ i64  ┆ i64       │\\n\",\n",
    "       \"╞══════╪═══════════╡\\n\",\n",
    "       \"│ 500  ┆ 500       │\\n\",\n",
    "       \"│ 0    ┆ 500       │\\n\",\n",
    "       \"│ 0    ┆ 500       │\\n\",\n",
    "       \"│ -200 ┆ 300       │\\n\",\n",
    "       \"│ 300  ┆ 600       │\\n\",\n",
    "       \"│ 0    ┆ 600       │\\n\",\n",
    "       \"│ -400 ┆ 200       │\\n\",\n",
    "       \"└──────┴───────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 15,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d = pl.DataFrame({\\\"n\\\": [500, 0, 0, -200, 300, 0, -400]})\\n\",\n",
    "    \"d.with_columns(running_n=pl.col.n.cum_sum())\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 16,\n",
    "   \"id\": \"d3f2e6c8-23c1-43eb-9c97-d423a735b3e3\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (10, 3)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>n</th><th>name</th><th>runing_n</th></tr><tr><td>i64</td><td>str</td><td>i64</td></tr></thead><tbody><tr><td>500</td><td>&quot;A&quot;</td><td>500</td></tr><tr><td>0</td><td>&quot;A&quot;</td><td>500</td></tr><tr><td>-200</td><td>&quot;A&quot;</td><td>300</td></tr><tr><td>300</td><td>&quot;A&quot;</td><td>600</td></tr><tr><td>-400</td><td>&quot;A&quot;</td><td>200</td></tr><tr><td>800</td><td>&quot;B&quot;</td><td>800</td></tr><tr><td>300</td><td>&quot;B&quot;</td><td>1100</td></tr><tr><td>-200</td><td>&quot;B&quot;</td><td>900</td></tr><tr><td>100</td><td>&quot;B&quot;</td><td>1000</td></tr><tr><td>-400</td><td>&quot;B&quot;</td><td>600</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (10, 3)\\n\",\n",
    "       \"┌──────┬──────┬──────────┐\\n\",\n",
    "       \"│ n    ┆ name ┆ runing_n │\\n\",\n",
    "       \"│ ---  ┆ ---  ┆ ---      │\\n\",\n",
    "       \"│ i64  ┆ str  ┆ i64      │\\n\",\n",
    "       \"╞══════╪══════╪══════════╡\\n\",\n",
    "       \"│ 500  ┆ A    ┆ 500      │\\n\",\n",
    "       \"│ 0    ┆ A    ┆ 500      │\\n\",\n",
    "       \"│ -200 ┆ A    ┆ 300      │\\n\",\n",
    "       \"│ 300  ┆ A    ┆ 600      │\\n\",\n",
    "       \"│ -400 ┆ A    ┆ 200      │\\n\",\n",
    "       \"│ 800  ┆ B    ┆ 800      │\\n\",\n",
    "       \"│ 300  ┆ B    ┆ 1100     │\\n\",\n",
    "       \"│ -200 ┆ B    ┆ 900      │\\n\",\n",
    "       \"│ 100  ┆ B    ┆ 1000     │\\n\",\n",
    "       \"│ -400 ┆ B    ┆ 600      │\\n\",\n",
    "       \"└──────┴──────┴──────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 16,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"dd1 = pl.DataFrame({\\\"n\\\": [500, 0, -200, 300, -400]}).with_columns(name=pl.lit(\\\"A\\\"))\\n\",\n",
    "    \"dd2 = pl.DataFrame({\\\"n\\\": [800, 300, -200, 100, -400]}).with_columns(name=pl.lit(\\\"B\\\"))\\n\",\n",
    "    \"dd = pl.concat([dd1, dd2])\\n\",\n",
    "    \"dd.with_columns(\\n\",\n",
    "    \"    runing_n=pl.col.n.cum_sum().over(\\\"name\\\"),\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 17,\n",
    "   \"id\": \"8f796cd2-55e2-4a47-9a39-ab00081c51b8\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"import tushare as ts\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 18,\n",
    "   \"id\": \"d1c61680-9fc2-4101-8291-0e4344df2350\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"pro = ts.pro_api()\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 20,\n",
    "   \"id\": \"6b523fb0-5732-4f5d-9d59-721c6be8fb61\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"datetime.date(2022, 7, 11)\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 20,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"start_date\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 21,\n",
    "   \"id\": \"e14e4f6d-944e-4002-b315-9f94b4e446ae\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"datetime.date(2023, 10, 31)\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 21,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"end_date\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 30,\n",
    "   \"id\": \"2710148a-9f43-4d4e-8a34-00c096156253\",\n",
    "   \"metadata\": {\n",
    "    \"jupyter\": {\n",
    "     \"source_hidden\": true\n",
    "    }\n",
    "   },\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"'20220711'\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 30,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"f\\\"{start_date:%Y%m%d}\\\"\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 31,\n",
    "   \"id\": \"274cee8e-5238-4166-82fc-c554a8e9ee35\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"'20231031'\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 31,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"format(end_date, \\\"%Y%m%d\\\")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 33,\n",
    "   \"id\": \"076ca449-3195-4160-90c1-882fb98c34dd\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (318, 11)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>ts_code</th><th>trade_date</th><th>open</th><th>high</th><th>low</th><th>close</th><th>pre_close</th><th>change</th><th>pct_chg</th><th>vol</th><th>amount</th></tr><tr><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20231031&quot;</td><td>14.75</td><td>14.9</td><td>14.59</td><td>14.7</td><td>14.75</td><td>-0.05</td><td>-0.339</td><td>65859.96</td><td>96984.271</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20231030&quot;</td><td>13.88</td><td>14.89</td><td>13.88</td><td>14.75</td><td>13.93</td><td>0.82</td><td>5.8866</td><td>123932.16</td><td>180119.372</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20231027&quot;</td><td>13.7</td><td>13.98</td><td>13.51</td><td>13.93</td><td>13.64</td><td>0.29</td><td>2.1261</td><td>35782.0</td><td>49386.168</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20231026&quot;</td><td>13.49</td><td>13.68</td><td>13.4</td><td>13.64</td><td>13.62</td><td>0.02</td><td>0.1468</td><td>19215.0</td><td>26005.866</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20231025&quot;</td><td>13.65</td><td>13.77</td><td>13.58</td><td>13.62</td><td>13.67</td><td>-0.05</td><td>-0.3658</td><td>18484.0</td><td>25274.163</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20220715&quot;</td><td>13.61</td><td>13.66</td><td>13.12</td><td>13.13</td><td>13.59</td><td>-0.46</td><td>-3.3848</td><td>32967.65</td><td>44114.064</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20220714&quot;</td><td>13.54</td><td>13.75</td><td>13.5</td><td>13.59</td><td>13.54</td><td>0.05</td><td>0.3693</td><td>21967.0</td><td>29851.164</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20220713&quot;</td><td>13.55</td><td>13.63</td><td>13.39</td><td>13.54</td><td>13.61</td><td>-0.07</td><td>-0.5143</td><td>22793.0</td><td>30714.624</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20220712&quot;</td><td>13.65</td><td>13.69</td><td>13.41</td><td>13.61</td><td>13.65</td><td>-0.04</td><td>-0.293</td><td>29679.0</td><td>40146.31</td></tr><tr><td>&quot;002462.SZ&quot;</td><td>&quot;20220711&quot;</td><td>13.2</td><td>13.96</td><td>13.07</td><td>13.65</td><td>13.18</td><td>0.47</td><td>3.566</td><td>62827.0</td><td>85869.11</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (318, 11)\\n\",\n",
    "       \"┌─────────┬─────────┬───────┬───────┬───┬────────┬─────────┬─────────┬─────────┐\\n\",\n",
    "       \"│ ts_code ┆ trade_d ┆ open  ┆ high  ┆ … ┆ change ┆ pct_chg ┆ vol     ┆ amount  │\\n\",\n",
    "       \"│ ---     ┆ ate     ┆ ---   ┆ ---   ┆   ┆ ---    ┆ ---     ┆ ---     ┆ ---     │\\n\",\n",
    "       \"│ str     ┆ ---     ┆ f64   ┆ f64   ┆   ┆ f64    ┆ f64     ┆ f64     ┆ f64     │\\n\",\n",
    "       \"│         ┆ str     ┆       ┆       ┆   ┆        ┆         ┆         ┆         │\\n\",\n",
    "       \"╞═════════╪═════════╪═══════╪═══════╪═══╪════════╪═════════╪═════════╪═════════╡\\n\",\n",
    "       \"│ 002462. ┆ 2023103 ┆ 14.75 ┆ 14.9  ┆ … ┆ -0.05  ┆ -0.339  ┆ 65859.9 ┆ 96984.2 │\\n\",\n",
    "       \"│ SZ      ┆ 1       ┆       ┆       ┆   ┆        ┆         ┆ 6       ┆ 71      │\\n\",\n",
    "       \"│ 002462. ┆ 2023103 ┆ 13.88 ┆ 14.89 ┆ … ┆ 0.82   ┆ 5.8866  ┆ 123932. ┆ 180119. │\\n\",\n",
    "       \"│ SZ      ┆ 0       ┆       ┆       ┆   ┆        ┆         ┆ 16      ┆ 372     │\\n\",\n",
    "       \"│ 002462. ┆ 2023102 ┆ 13.7  ┆ 13.98 ┆ … ┆ 0.29   ┆ 2.1261  ┆ 35782.0 ┆ 49386.1 │\\n\",\n",
    "       \"│ SZ      ┆ 7       ┆       ┆       ┆   ┆        ┆         ┆         ┆ 68      │\\n\",\n",
    "       \"│ 002462. ┆ 2023102 ┆ 13.49 ┆ 13.68 ┆ … ┆ 0.02   ┆ 0.1468  ┆ 19215.0 ┆ 26005.8 │\\n\",\n",
    "       \"│ SZ      ┆ 6       ┆       ┆       ┆   ┆        ┆         ┆         ┆ 66      │\\n\",\n",
    "       \"│ 002462. ┆ 2023102 ┆ 13.65 ┆ 13.77 ┆ … ┆ -0.05  ┆ -0.3658 ┆ 18484.0 ┆ 25274.1 │\\n\",\n",
    "       \"│ SZ      ┆ 5       ┆       ┆       ┆   ┆        ┆         ┆         ┆ 63      │\\n\",\n",
    "       \"│ …       ┆ …       ┆ …     ┆ …     ┆ … ┆ …      ┆ …       ┆ …       ┆ …       │\\n\",\n",
    "       \"│ 002462. ┆ 2022071 ┆ 13.61 ┆ 13.66 ┆ … ┆ -0.46  ┆ -3.3848 ┆ 32967.6 ┆ 44114.0 │\\n\",\n",
    "       \"│ SZ      ┆ 5       ┆       ┆       ┆   ┆        ┆         ┆ 5       ┆ 64      │\\n\",\n",
    "       \"│ 002462. ┆ 2022071 ┆ 13.54 ┆ 13.75 ┆ … ┆ 0.05   ┆ 0.3693  ┆ 21967.0 ┆ 29851.1 │\\n\",\n",
    "       \"│ SZ      ┆ 4       ┆       ┆       ┆   ┆        ┆         ┆         ┆ 64      │\\n\",\n",
    "       \"│ 002462. ┆ 2022071 ┆ 13.55 ┆ 13.63 ┆ … ┆ -0.07  ┆ -0.5143 ┆ 22793.0 ┆ 30714.6 │\\n\",\n",
    "       \"│ SZ      ┆ 3       ┆       ┆       ┆   ┆        ┆         ┆         ┆ 24      │\\n\",\n",
    "       \"│ 002462. ┆ 2022071 ┆ 13.65 ┆ 13.69 ┆ … ┆ -0.04  ┆ -0.293  ┆ 29679.0 ┆ 40146.3 │\\n\",\n",
    "       \"│ SZ      ┆ 2       ┆       ┆       ┆   ┆        ┆         ┆         ┆ 1       │\\n\",\n",
    "       \"│ 002462. ┆ 2022071 ┆ 13.2  ┆ 13.96 ┆ … ┆ 0.47   ┆ 3.566   ┆ 62827.0 ┆ 85869.1 │\\n\",\n",
    "       \"│ SZ      ┆ 1       ┆       ┆       ┆   ┆        ┆         ┆         ┆ 1       │\\n\",\n",
    "       \"└─────────┴─────────┴───────┴───────┴───┴────────┴─────────┴─────────┴─────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 33,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"hq = pro.daily(\\n\",\n",
    "    \"    ts_code=\\\"002462.SZ\\\",\\n\",\n",
    "    \"    start_date=format(start_date, \\\"%Y%m%d\\\"),\\n\",\n",
    "    \"    end_date=format(end_date, \\\"%Y%m%d\\\"),\\n\",\n",
    "    \")\\n\",\n",
    "    \"hq = pl.from_pandas(hq)\\n\",\n",
    "    \"hq\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 34,\n",
    "   \"id\": \"6b52cb11-cfce-451b-b20a-b443fc096bf3\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (358, 18)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>1</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:33:37&quot;</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>4.05</td><td>34400.0</td><td>139320.0</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>-139342.29</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>2</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:34:24&quot;</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>3.65</td><td>38300.0</td><td>139795.0</td><td>22.37</td><td>0.0</td><td>1.38</td><td>0.0</td><td>-139818.75</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>3</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:36:30&quot;</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>6.54</td><td>21400.0</td><td>139956.0</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-139979.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>4</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:37:25&quot;</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>2.59</td><td>54000.0</td><td>139860.0</td><td>22.38</td><td>0.0</td><td>1.42</td><td>0.0</td><td>-139883.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>5</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:38:16&quot;</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>13.51</td><td>10400.0</td><td>140504.0</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-140526.48</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>359</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:31:53&quot;</td><td>&quot;002956&quot;</td><td>&quot;西麦食品&quot;</td><td>&quot;卖出&quot;</td><td>14.13</td><td>5000.0</td><td>70650.0</td><td>6.74</td><td>35.35</td><td>0.0</td><td>0.0</td><td>70607.91</td><td>0.000095</td><td>0.0005</td><td>0.0</td></tr><tr><td>360</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:39:57&quot;</td><td>&quot;603214&quot;</td><td>&quot;爱婴室&quot;</td><td>&quot;买入&quot;</td><td>15.84</td><td>3100.0</td><td>49104.0</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>-49109.51</td><td>0.000102</td><td>0.0</td><td>0.00001</td></tr><tr><td>361</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:40:55&quot;</td><td>&quot;300132&quot;</td><td>&quot;青松股份&quot;</td><td>&quot;买入&quot;</td><td>5.21</td><td>9600.0</td><td>50016.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-50021.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr><tr><td>362</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:43:13&quot;</td><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>&quot;买入&quot;</td><td>5.91</td><td>8400.0</td><td>49644.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49649.0</td><td>0.000101</td><td>0.0</td><td>0.0</td></tr><tr><td>363</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:44:45&quot;</td><td>&quot;002111&quot;</td><td>&quot;威海广泰&quot;</td><td>&quot;买入&quot;</td><td>9.24</td><td>5400.0</td><td>49896.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49901.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (358, 18)\\n\",\n",
    "       \"┌──────┬─────────┬─────────┬─────────┬───┬─────────┬─────────┬────────┬────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商    ┆ 交易日  ┆ 交易时  ┆ … ┆ 发生金  ┆ 手续费  ┆ 印花税 ┆ 过户费 │\\n\",\n",
    "       \"│ ---  ┆ ---     ┆ 期      ┆ 间      ┆   ┆ 额      ┆ 率      ┆ 率     ┆ 率     │\\n\",\n",
    "       \"│ u32  ┆ str     ┆ ---     ┆ ---     ┆   ┆ ---     ┆ ---     ┆ ---    ┆ ---    │\\n\",\n",
    "       \"│      ┆         ┆ date    ┆ str     ┆   ┆ f64     ┆ f64     ┆ f64    ┆ f64    │\\n\",\n",
    "       \"╞══════╪═════════╪═════════╪═════════╪═══╪═════════╪═════════╪════════╪════════╡\\n\",\n",
    "       \"│ 1    ┆ 湘财    ┆ 2022-07 ┆ 09:33:3 ┆ … ┆ -139342 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 7       ┆   ┆ .29     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 2    ┆ 湘财    ┆ 2022-07 ┆ 09:34:2 ┆ … ┆ -139818 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 4       ┆   ┆ .75     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 3    ┆ 湘财    ┆ 2022-07 ┆ 09:36:3 ┆ … ┆ -139979 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 0       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 4    ┆ 湘财    ┆ 2022-07 ┆ 09:37:2 ┆ … ┆ -139883 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 5       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 5    ┆ 湘财    ┆ 2022-07 ┆ 09:38:1 ┆ … ┆ -140526 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 6       ┆   ┆ .48     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ …    ┆ …       ┆ …       ┆ …       ┆ … ┆ …       ┆ …       ┆ …      ┆ …      │\\n\",\n",
    "       \"│ 359  ┆ 海通两  ┆ 2023-10 ┆ 09:31:5 ┆ … ┆ 70607.9 ┆ 0.00009 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 1       ┆ 5       ┆        ┆        │\\n\",\n",
    "       \"│ 360  ┆ 海通两  ┆ 2023-10 ┆ 09:39:5 ┆ … ┆ -49109. ┆ 0.00010 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 7       ┆   ┆ 51      ┆ 2       ┆        ┆ 1      │\\n\",\n",
    "       \"│ 361  ┆ 海通两  ┆ 2023-10 ┆ 09:40:5 ┆ … ┆ -50021. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 362  ┆ 海通两  ┆ 2023-10 ┆ 09:43:1 ┆ … ┆ -49649. ┆ 0.00010 ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 0       ┆ 1       ┆        ┆        │\\n\",\n",
    "       \"│ 363  ┆ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ … ┆ -49901. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"└──────┴─────────┴─────────┴─────────┴───┴─────────┴─────────┴────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 34,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d1\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 35,\n",
    "   \"id\": \"dd4955d6-66ff-4b62-9ef6-55468813d2db\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (4_489, 19)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>交易日期</th><th>证券代码</th><th>序号</th><th>券商</th><th>交易时间</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th><th>结余数量</th></tr><tr><td>date</td><td>str</td><td>u32</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>2022-07-11</td><td>&quot;000900&quot;</td><td>1</td><td>&quot;湘财&quot;</td><td>&quot;09:33:37&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>4.05</td><td>34400.0</td><td>139320.0</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>-139342.29</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>34400.0</td></tr><tr><td>2022-07-11</td><td>&quot;002462&quot;</td><td>5</td><td>&quot;湘财&quot;</td><td>&quot;09:38:16&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>13.51</td><td>10400.0</td><td>140504.0</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-140526.48</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>10400.0</td></tr><tr><td>2022-07-11</td><td>&quot;600894&quot;</td><td>3</td><td>&quot;湘财&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>6.54</td><td>21400.0</td><td>139956.0</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-139979.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>21400.0</td></tr><tr><td>2022-07-11</td><td>&quot;601077&quot;</td><td>2</td><td>&quot;湘财&quot;</td><td>&quot;09:34:24&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>3.65</td><td>38300.0</td><td>139795.0</td><td>22.37</td><td>0.0</td><td>1.38</td><td>0.0</td><td>-139818.75</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>38300.0</td></tr><tr><td>2022-07-11</td><td>&quot;601992&quot;</td><td>4</td><td>&quot;湘财&quot;</td><td>&quot;09:37:25&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>2.59</td><td>54000.0</td><td>139860.0</td><td>22.38</td><td>0.0</td><td>1.42</td><td>0.0</td><td>-139883.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>54000.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2023-10-31</td><td>&quot;300132&quot;</td><td>361</td><td>&quot;海通两融&quot;</td><td>&quot;09:40:55&quot;</td><td>&quot;青松股份&quot;</td><td>&quot;买入&quot;</td><td>5.21</td><td>9600.0</td><td>50016.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-50021.0</td><td>0.0001</td><td>0.0</td><td>0.0</td><td>9600.0</td></tr><tr><td>2023-10-31</td><td>&quot;300215&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>20000.0</td></tr><tr><td>2023-10-31</td><td>&quot;600525&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>8500.0</td></tr><tr><td>2023-10-31</td><td>&quot;603214&quot;</td><td>360</td><td>&quot;海通两融&quot;</td><td>&quot;09:39:57&quot;</td><td>&quot;爱婴室&quot;</td><td>&quot;买入&quot;</td><td>15.84</td><td>3100.0</td><td>49104.0</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>-49109.51</td><td>0.000102</td><td>0.0</td><td>0.00001</td><td>3100.0</td></tr><tr><td>2023-10-31</td><td>&quot;688660&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>20200.0</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (4_489, 19)\\n\",\n",
    "       \"┌─────────┬─────────┬──────┬─────────┬───┬─────────┬─────────┬────────┬────────┐\\n\",\n",
    "       \"│ 交易日  ┆ 证券代  ┆ 序号 ┆ 券商    ┆ … ┆ 手续费  ┆ 印花税  ┆ 过户费 ┆ 结余数 │\\n\",\n",
    "       \"│ 期      ┆ 码      ┆ ---  ┆ ---     ┆   ┆ 率      ┆ 率      ┆ 率     ┆ 量     │\\n\",\n",
    "       \"│ ---     ┆ ---     ┆ u32  ┆ str     ┆   ┆ ---     ┆ ---     ┆ ---    ┆ ---    │\\n\",\n",
    "       \"│ date    ┆ str     ┆      ┆         ┆   ┆ f64     ┆ f64     ┆ f64    ┆ f64    │\\n\",\n",
    "       \"╞═════════╪═════════╪══════╪═════════╪═══╪═════════╪═════════╪════════╪════════╡\\n\",\n",
    "       \"│ 2022-07 ┆ 000900  ┆ 1    ┆ 湘财    ┆ … ┆ 0.00016 ┆ 0.0     ┆ 0.0000 ┆ 34400. │\\n\",\n",
    "       \"│ -11     ┆         ┆      ┆         ┆   ┆         ┆         ┆ 1      ┆ 0      │\\n\",\n",
    "       \"│ 2022-07 ┆ 002462  ┆ 5    ┆ 湘财    ┆ … ┆ 0.00016 ┆ 0.0     ┆ 0.0000 ┆ 10400. │\\n\",\n",
    "       \"│ -11     ┆         ┆      ┆         ┆   ┆         ┆         ┆ 1      ┆ 0      │\\n\",\n",
    "       \"│ 2022-07 ┆ 600894  ┆ 3    ┆ 湘财    ┆ … ┆ 0.00016 ┆ 0.0     ┆ 0.0000 ┆ 21400. │\\n\",\n",
    "       \"│ -11     ┆         ┆      ┆         ┆   ┆         ┆         ┆ 1      ┆ 0      │\\n\",\n",
    "       \"│ 2022-07 ┆ 601077  ┆ 2    ┆ 湘财    ┆ … ┆ 0.00016 ┆ 0.0     ┆ 0.0000 ┆ 38300. │\\n\",\n",
    "       \"│ -11     ┆         ┆      ┆         ┆   ┆         ┆         ┆ 1      ┆ 0      │\\n\",\n",
    "       \"│ 2022-07 ┆ 601992  ┆ 4    ┆ 湘财    ┆ … ┆ 0.00016 ┆ 0.0     ┆ 0.0000 ┆ 54000. │\\n\",\n",
    "       \"│ -11     ┆         ┆      ┆         ┆   ┆         ┆         ┆ 1      ┆ 0      │\\n\",\n",
    "       \"│ …       ┆ …       ┆ …    ┆ …       ┆ … ┆ …       ┆ …       ┆ …      ┆ …      │\\n\",\n",
    "       \"│ 2023-10 ┆ 300132  ┆ 361  ┆ 海通两  ┆ … ┆ 0.0001  ┆ 0.0     ┆ 0.0    ┆ 9600.0 │\\n\",\n",
    "       \"│ -31     ┆         ┆      ┆ 融      ┆   ┆         ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 2023-10 ┆ 300215  ┆ null ┆ null    ┆ … ┆ null    ┆ null    ┆ null   ┆ 20000. │\\n\",\n",
    "       \"│ -31     ┆         ┆      ┆         ┆   ┆         ┆         ┆        ┆ 0      │\\n\",\n",
    "       \"│ 2023-10 ┆ 600525  ┆ null ┆ null    ┆ … ┆ null    ┆ null    ┆ null   ┆ 8500.0 │\\n\",\n",
    "       \"│ -31     ┆         ┆      ┆         ┆   ┆         ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 2023-10 ┆ 603214  ┆ 360  ┆ 海通两  ┆ … ┆ 0.00010 ┆ 0.0     ┆ 0.0000 ┆ 3100.0 │\\n\",\n",
    "       \"│ -31     ┆         ┆      ┆ 融      ┆   ┆ 2       ┆         ┆ 1      ┆        │\\n\",\n",
    "       \"│ 2023-10 ┆ 688660  ┆ null ┆ null    ┆ … ┆ null    ┆ null    ┆ null   ┆ 20200. │\\n\",\n",
    "       \"│ -31     ┆         ┆      ┆         ┆   ┆         ┆         ┆        ┆ 0      │\\n\",\n",
    "       \"└─────────┴─────────┴──────┴─────────┴───┴─────────┴─────────┴────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 35,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d2\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 89,\n",
    "   \"id\": \"fd45c4bc-e583-46c6-8c22-d8358500e496\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"ts_codes = (\\n\",\n",
    "    \"    d1.select(\\n\",\n",
    "    \"        证券代码=(\\n\",\n",
    "    \"            pl.when(pl.col(\\\"证券代码\\\").str.head(1).is_in([\\\"0\\\", \\\"3\\\"]))\\n\",\n",
    "    \"            .then(pl.format(\\\"{}.SZ\\\", pl.col(\\\"证券代码\\\")))\\n\",\n",
    "    \"            .when(pl.col(\\\"证券代码\\\").str.head(1) == \\\"6\\\")\\n\",\n",
    "    \"            .then(pl.format(\\\"{}.SH\\\", pl.col(\\\"证券代码\\\")))\\n\",\n",
    "    \"        ),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .to_series()\\n\",\n",
    "    \"    .unique()\\n\",\n",
    "    \"    .sort()\\n\",\n",
    "    \"    .to_list()\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 90,\n",
    "   \"id\": \"6c2bba2e-25ae-4697-bcb2-5c496a1c4dce\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"['000096.SZ',\\n\",\n",
    "       \" '000532.SZ',\\n\",\n",
    "       \" '000559.SZ',\\n\",\n",
    "       \" '000599.SZ',\\n\",\n",
    "       \" '000655.SZ',\\n\",\n",
    "       \" '000698.SZ',\\n\",\n",
    "       \" '000712.SZ',\\n\",\n",
    "       \" '000717.SZ',\\n\",\n",
    "       \" '000751.SZ',\\n\",\n",
    "       \" '000823.SZ',\\n\",\n",
    "       \" '000900.SZ',\\n\",\n",
    "       \" '000903.SZ',\\n\",\n",
    "       \" '002023.SZ',\\n\",\n",
    "       \" '002054.SZ',\\n\",\n",
    "       \" '002055.SZ',\\n\",\n",
    "       \" '002106.SZ',\\n\",\n",
    "       \" '002111.SZ',\\n\",\n",
    "       \" '002136.SZ',\\n\",\n",
    "       \" '002224.SZ',\\n\",\n",
    "       \" '002225.SZ',\\n\",\n",
    "       \" '002228.SZ',\\n\",\n",
    "       \" '002288.SZ',\\n\",\n",
    "       \" '002331.SZ',\\n\",\n",
    "       \" '002381.SZ',\\n\",\n",
    "       \" '002382.SZ',\\n\",\n",
    "       \" '002392.SZ',\\n\",\n",
    "       \" '002440.SZ',\\n\",\n",
    "       \" '002442.SZ',\\n\",\n",
    "       \" '002462.SZ',\\n\",\n",
    "       \" '002479.SZ',\\n\",\n",
    "       \" '002492.SZ',\\n\",\n",
    "       \" '002521.SZ',\\n\",\n",
    "       \" '002616.SZ',\\n\",\n",
    "       \" '002637.SZ',\\n\",\n",
    "       \" '002661.SZ',\\n\",\n",
    "       \" '002672.SZ',\\n\",\n",
    "       \" '002688.SZ',\\n\",\n",
    "       \" '002702.SZ',\\n\",\n",
    "       \" '002734.SZ',\\n\",\n",
    "       \" '002743.SZ',\\n\",\n",
    "       \" '002753.SZ',\\n\",\n",
    "       \" '002842.SZ',\\n\",\n",
    "       \" '002946.SZ',\\n\",\n",
    "       \" '002956.SZ',\\n\",\n",
    "       \" '002996.SZ',\\n\",\n",
    "       \" '002998.SZ',\\n\",\n",
    "       \" '300006.SZ',\\n\",\n",
    "       \" '300016.SZ',\\n\",\n",
    "       \" '300022.SZ',\\n\",\n",
    "       \" '300107.SZ',\\n\",\n",
    "       \" '300132.SZ',\\n\",\n",
    "       \" '300155.SZ',\\n\",\n",
    "       \" '300190.SZ',\\n\",\n",
    "       \" '300214.SZ',\\n\",\n",
    "       \" '300215.SZ',\\n\",\n",
    "       \" '300221.SZ',\\n\",\n",
    "       \" '300241.SZ',\\n\",\n",
    "       \" '300242.SZ',\\n\",\n",
    "       \" '300259.SZ',\\n\",\n",
    "       \" '300279.SZ',\\n\",\n",
    "       \" '300281.SZ',\\n\",\n",
    "       \" '300283.SZ',\\n\",\n",
    "       \" '300304.SZ',\\n\",\n",
    "       \" '300368.SZ',\\n\",\n",
    "       \" '300385.SZ',\\n\",\n",
    "       \" '300422.SZ',\\n\",\n",
    "       \" '300429.SZ',\\n\",\n",
    "       \" '300464.SZ',\\n\",\n",
    "       \" '300473.SZ',\\n\",\n",
    "       \" '300538.SZ',\\n\",\n",
    "       \" '300543.SZ',\\n\",\n",
    "       \" '300641.SZ',\\n\",\n",
    "       \" '300642.SZ',\\n\",\n",
    "       \" '300651.SZ',\\n\",\n",
    "       \" '300701.SZ',\\n\",\n",
    "       \" '300708.SZ',\\n\",\n",
    "       \" '300905.SZ',\\n\",\n",
    "       \" '600015.SH',\\n\",\n",
    "       \" '600022.SH',\\n\",\n",
    "       \" '600051.SH',\\n\",\n",
    "       \" '600097.SH',\\n\",\n",
    "       \" '600120.SH',\\n\",\n",
    "       \" '600178.SH',\\n\",\n",
    "       \" '600231.SH',\\n\",\n",
    "       \" '600261.SH',\\n\",\n",
    "       \" '600269.SH',\\n\",\n",
    "       \" '600273.SH',\\n\",\n",
    "       \" '600287.SH',\\n\",\n",
    "       \" '600292.SH',\\n\",\n",
    "       \" '600300.SH',\\n\",\n",
    "       \" '600336.SH',\\n\",\n",
    "       \" '600408.SH',\\n\",\n",
    "       \" '600429.SH',\\n\",\n",
    "       \" '600513.SH',\\n\",\n",
    "       \" '600525.SH',\\n\",\n",
    "       \" '600590.SH',\\n\",\n",
    "       \" '600597.SH',\\n\",\n",
    "       \" '600626.SH',\\n\",\n",
    "       \" '600638.SH',\\n\",\n",
    "       \" '600643.SH',\\n\",\n",
    "       \" '600648.SH',\\n\",\n",
    "       \" '600727.SH',\\n\",\n",
    "       \" '600729.SH',\\n\",\n",
    "       \" '600735.SH',\\n\",\n",
    "       \" '600793.SH',\\n\",\n",
    "       \" '600800.SH',\\n\",\n",
    "       \" '600810.SH',\\n\",\n",
    "       \" '600827.SH',\\n\",\n",
    "       \" '600829.SH',\\n\",\n",
    "       \" '600835.SH',\\n\",\n",
    "       \" '600839.SH',\\n\",\n",
    "       \" '600843.SH',\\n\",\n",
    "       \" '600844.SH',\\n\",\n",
    "       \" '600894.SH',\\n\",\n",
    "       \" '600960.SH',\\n\",\n",
    "       \" '600967.SH',\\n\",\n",
    "       \" '600980.SH',\\n\",\n",
    "       \" '601002.SH',\\n\",\n",
    "       \" '601077.SH',\\n\",\n",
    "       \" '601166.SH',\\n\",\n",
    "       \" '601992.SH',\\n\",\n",
    "       \" '603002.SH',\\n\",\n",
    "       \" '603111.SH',\\n\",\n",
    "       \" '603113.SH',\\n\",\n",
    "       \" '603186.SH',\\n\",\n",
    "       \" '603214.SH',\\n\",\n",
    "       \" '603385.SH',\\n\",\n",
    "       \" '603386.SH',\\n\",\n",
    "       \" '603577.SH',\\n\",\n",
    "       \" '603626.SH',\\n\",\n",
    "       \" '603686.SH',\\n\",\n",
    "       \" '603739.SH',\\n\",\n",
    "       \" '603878.SH',\\n\",\n",
    "       \" '603897.SH',\\n\",\n",
    "       \" '603967.SH',\\n\",\n",
    "       \" '603988.SH',\\n\",\n",
    "       \" '605066.SH',\\n\",\n",
    "       \" '605158.SH',\\n\",\n",
    "       \" '605196.SH',\\n\",\n",
    "       \" '605258.SH',\\n\",\n",
    "       \" '605288.SH',\\n\",\n",
    "       \" '688011.SH',\\n\",\n",
    "       \" '688069.SH',\\n\",\n",
    "       \" '688165.SH',\\n\",\n",
    "       \" '688299.SH',\\n\",\n",
    "       \" '688321.SH',\\n\",\n",
    "       \" '688360.SH',\\n\",\n",
    "       \" '688393.SH',\\n\",\n",
    "       \" '688660.SH']\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 90,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"ts_codes\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 56,\n",
    "   \"id\": \"0dbb89ae-f2c5-42ca-b150-0e97221bb8d8\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"149\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 56,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"len(ts_codes)\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 91,\n",
    "   \"id\": \"20608eb2-d15c-44a1-8518-98ed609d4bb8\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"from tqdm.notebook import tqdm\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 92,\n",
    "   \"id\": \"8b15f361-a0bb-4e67-8a8f-1be98f88f68f\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"application/vnd.jupyter.widget-view+json\": {\n",
    "       \"model_id\": \"cb30fbec852d4ebf80e47f9379967989\",\n",
    "       \"version_major\": 2,\n",
    "       \"version_minor\": 0\n",
    "      },\n",
    "      \"text/plain\": [\n",
    "       \"  0%|          | 0/149 [00:00<?, ?it/s]\"\n",
    "      ]\n",
    "     },\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"display_data\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"hq = [\\n\",\n",
    "    \"    pl.from_pandas(\\n\",\n",
    "    \"        pro.daily(\\n\",\n",
    "    \"            ts_code=ts_code,\\n\",\n",
    "    \"            start_date=format(start_date, \\\"%Y%m%d\\\"),\\n\",\n",
    "    \"            end_date=format(end_date, \\\"%Y%m%d\\\"),\\n\",\n",
    "    \"        )\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    for ts_code in tqdm(ts_codes)\\n\",\n",
    "    \"]\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 84,\n",
    "   \"id\": \"0fc4aa48-234d-47db-bb60-2359610182e2\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/plain\": [\n",
    "       \"[polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame,\\n\",\n",
    "       \" polars.dataframe.frame.DataFrame]\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 84,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"[type(i) for i in hq]\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 95,\n",
    "   \"id\": \"99b3a62c-e882-4048-b38c-33ec641fb3ab\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"hq = pl.concat(hq)\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 98,\n",
    "   \"id\": \"8f8f4b04-3cd6-4db2-9cc8-c97fead38926\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"name\": \"stdout\",\n",
    "     \"output_type\": \"stream\",\n",
    "     \"text\": [\n",
    "      \"/c/Users/ASUS/repo/week08\\n\"\n",
    "     ]\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"!pwd\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 99,\n",
    "   \"id\": \"fda838a3-2c93-47f3-814d-b13631faf68f\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"hq.write_parquet(\\\"daily.parquet\\\")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 111,\n",
    "   \"id\": \"37e2bf4f-3de5-4b12-a126-b808a804da25\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"hq = pl.read_parquet(\\\"daily.parquet\\\")\\n\",\n",
    "    \"\\n\",\n",
    "    \"hq = hq.with_columns(\\n\",\n",
    "    \"    pl.col(\\\"ts_code\\\").str.head(6),\\n\",\n",
    "    \"    pl.col(\\\"trade_date\\\").str.to_date(\\\"%Y%m%d\\\"),\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 109,\n",
    "   \"id\": \"59c86934-394b-44cb-a634-7f3c56543d97\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (358, 18)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>1</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:33:37&quot;</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>4.05</td><td>34400.0</td><td>139320.0</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>-139342.29</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>2</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:34:24&quot;</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>3.65</td><td>38300.0</td><td>139795.0</td><td>22.37</td><td>0.0</td><td>1.38</td><td>0.0</td><td>-139818.75</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>3</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:36:30&quot;</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>6.54</td><td>21400.0</td><td>139956.0</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-139979.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>4</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:37:25&quot;</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>2.59</td><td>54000.0</td><td>139860.0</td><td>22.38</td><td>0.0</td><td>1.42</td><td>0.0</td><td>-139883.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>5</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:38:16&quot;</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>13.51</td><td>10400.0</td><td>140504.0</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-140526.48</td><td>0.00016</td><td>0.0</td><td>0.00001</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>359</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:31:53&quot;</td><td>&quot;002956&quot;</td><td>&quot;西麦食品&quot;</td><td>&quot;卖出&quot;</td><td>14.13</td><td>5000.0</td><td>70650.0</td><td>6.74</td><td>35.35</td><td>0.0</td><td>0.0</td><td>70607.91</td><td>0.000095</td><td>0.0005</td><td>0.0</td></tr><tr><td>360</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:39:57&quot;</td><td>&quot;603214&quot;</td><td>&quot;爱婴室&quot;</td><td>&quot;买入&quot;</td><td>15.84</td><td>3100.0</td><td>49104.0</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>-49109.51</td><td>0.000102</td><td>0.0</td><td>0.00001</td></tr><tr><td>361</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:40:55&quot;</td><td>&quot;300132&quot;</td><td>&quot;青松股份&quot;</td><td>&quot;买入&quot;</td><td>5.21</td><td>9600.0</td><td>50016.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-50021.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr><tr><td>362</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:43:13&quot;</td><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>&quot;买入&quot;</td><td>5.91</td><td>8400.0</td><td>49644.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49649.0</td><td>0.000101</td><td>0.0</td><td>0.0</td></tr><tr><td>363</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:44:45&quot;</td><td>&quot;002111&quot;</td><td>&quot;威海广泰&quot;</td><td>&quot;买入&quot;</td><td>9.24</td><td>5400.0</td><td>49896.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49901.0</td><td>0.0001</td><td>0.0</td><td>0.0</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (358, 18)\\n\",\n",
    "       \"┌──────┬─────────┬─────────┬─────────┬───┬─────────┬─────────┬────────┬────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商    ┆ 交易日  ┆ 交易时  ┆ … ┆ 发生金  ┆ 手续费  ┆ 印花税 ┆ 过户费 │\\n\",\n",
    "       \"│ ---  ┆ ---     ┆ 期      ┆ 间      ┆   ┆ 额      ┆ 率      ┆ 率     ┆ 率     │\\n\",\n",
    "       \"│ u32  ┆ str     ┆ ---     ┆ ---     ┆   ┆ ---     ┆ ---     ┆ ---    ┆ ---    │\\n\",\n",
    "       \"│      ┆         ┆ date    ┆ str     ┆   ┆ f64     ┆ f64     ┆ f64    ┆ f64    │\\n\",\n",
    "       \"╞══════╪═════════╪═════════╪═════════╪═══╪═════════╪═════════╪════════╪════════╡\\n\",\n",
    "       \"│ 1    ┆ 湘财    ┆ 2022-07 ┆ 09:33:3 ┆ … ┆ -139342 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 7       ┆   ┆ .29     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 2    ┆ 湘财    ┆ 2022-07 ┆ 09:34:2 ┆ … ┆ -139818 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 4       ┆   ┆ .75     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 3    ┆ 湘财    ┆ 2022-07 ┆ 09:36:3 ┆ … ┆ -139979 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 0       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 4    ┆ 湘财    ┆ 2022-07 ┆ 09:37:2 ┆ … ┆ -139883 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 5       ┆   ┆ .8      ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ 5    ┆ 湘财    ┆ 2022-07 ┆ 09:38:1 ┆ … ┆ -140526 ┆ 0.00016 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 6       ┆   ┆ .48     ┆         ┆        ┆ 1      │\\n\",\n",
    "       \"│ …    ┆ …       ┆ …       ┆ …       ┆ … ┆ …       ┆ …       ┆ …      ┆ …      │\\n\",\n",
    "       \"│ 359  ┆ 海通两  ┆ 2023-10 ┆ 09:31:5 ┆ … ┆ 70607.9 ┆ 0.00009 ┆ 0.0005 ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 1       ┆ 5       ┆        ┆        │\\n\",\n",
    "       \"│ 360  ┆ 海通两  ┆ 2023-10 ┆ 09:39:5 ┆ … ┆ -49109. ┆ 0.00010 ┆ 0.0    ┆ 0.0000 │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 7       ┆   ┆ 51      ┆ 2       ┆        ┆ 1      │\\n\",\n",
    "       \"│ 361  ┆ 海通两  ┆ 2023-10 ┆ 09:40:5 ┆ … ┆ -50021. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"│ 362  ┆ 海通两  ┆ 2023-10 ┆ 09:43:1 ┆ … ┆ -49649. ┆ 0.00010 ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆ 0       ┆ 1       ┆        ┆        │\\n\",\n",
    "       \"│ 363  ┆ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ … ┆ -49901. ┆ 0.0001  ┆ 0.0    ┆ 0.0    │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆ 0       ┆         ┆        ┆        │\\n\",\n",
    "       \"└──────┴─────────┴─────────┴─────────┴───┴─────────┴─────────┴────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 109,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d1\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 119,\n",
    "   \"id\": \"92331efd-8d07-4b62-80da-94ef7c7ca676\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (358, 27)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th><th>open</th><th>high</th><th>low</th><th>close</th><th>pre_close</th><th>change</th><th>pct_chg</th><th>vol</th><th>amount</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>1</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:33:37&quot;</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>4.05</td><td>34400.0</td><td>139320.0</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>-139342.29</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>4.08</td><td>4.13</td><td>4.04</td><td>4.12</td><td>4.06</td><td>0.06</td><td>1.4778</td><td>89030.64</td><td>36352.212</td></tr><tr><td>2</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:34:24&quot;</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>3.65</td><td>38300.0</td><td>139795.0</td><td>22.37</td><td>0.0</td><td>1.38</td><td>0.0</td><td>-139818.75</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>3.65</td><td>3.68</td><td>3.64</td><td>3.66</td><td>3.65</td><td>0.01</td><td>0.274</td><td>370994.07</td><td>135739.515</td></tr><tr><td>3</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:36:30&quot;</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>6.54</td><td>21400.0</td><td>139956.0</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-139979.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>6.57</td><td>6.57</td><td>6.49</td><td>6.51</td><td>6.57</td><td>-0.06</td><td>-0.9132</td><td>20737.5</td><td>13537.134</td></tr><tr><td>4</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:37:25&quot;</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>2.59</td><td>54000.0</td><td>139860.0</td><td>22.38</td><td>0.0</td><td>1.42</td><td>0.0</td><td>-139883.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>2.61</td><td>2.62</td><td>2.58</td><td>2.59</td><td>2.61</td><td>-0.02</td><td>-0.7663</td><td>247321.0</td><td>64052.01</td></tr><tr><td>5</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:38:16&quot;</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>13.51</td><td>10400.0</td><td>140504.0</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-140526.48</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>13.2</td><td>13.96</td><td>13.07</td><td>13.65</td><td>13.18</td><td>0.47</td><td>3.566</td><td>62827.0</td><td>85869.11</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>359</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:31:53&quot;</td><td>&quot;002956&quot;</td><td>&quot;西麦食品&quot;</td><td>&quot;卖出&quot;</td><td>14.13</td><td>5000.0</td><td>70650.0</td><td>6.74</td><td>35.35</td><td>0.0</td><td>0.0</td><td>70607.91</td><td>0.000095</td><td>0.0005</td><td>0.0</td><td>14.2</td><td>14.27</td><td>14.01</td><td>14.07</td><td>14.21</td><td>-0.14</td><td>-0.9852</td><td>17859.2</td><td>25247.849</td></tr><tr><td>360</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:39:57&quot;</td><td>&quot;603214&quot;</td><td>&quot;爱婴室&quot;</td><td>&quot;买入&quot;</td><td>15.84</td><td>3100.0</td><td>49104.0</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>-49109.51</td><td>0.000102</td><td>0.0</td><td>0.00001</td><td>15.81</td><td>15.93</td><td>15.65</td><td>15.78</td><td>15.8</td><td>-0.02</td><td>-0.1266</td><td>18384.12</td><td>29025.236</td></tr><tr><td>361</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:40:55&quot;</td><td>&quot;300132&quot;</td><td>&quot;青松股份&quot;</td><td>&quot;买入&quot;</td><td>5.21</td><td>9600.0</td><td>50016.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-50021.0</td><td>0.0001</td><td>0.0</td><td>0.0</td><td>5.18</td><td>5.32</td><td>5.17</td><td>5.25</td><td>5.17</td><td>0.08</td><td>1.5474</td><td>88442.01</td><td>46306.236</td></tr><tr><td>362</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:43:13&quot;</td><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>&quot;买入&quot;</td><td>5.91</td><td>8400.0</td><td>49644.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49649.0</td><td>0.000101</td><td>0.0</td><td>0.0</td><td>5.87</td><td>5.94</td><td>5.86</td><td>5.91</td><td>5.87</td><td>0.04</td><td>0.6814</td><td>40253.0</td><td>23766.196</td></tr><tr><td>363</td><td>&quot;海通两融&quot;</td><td>2023-10-31</td><td>&quot;09:44:45&quot;</td><td>&quot;002111&quot;</td><td>&quot;威海广泰&quot;</td><td>&quot;买入&quot;</td><td>9.24</td><td>5400.0</td><td>49896.0</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-49901.0</td><td>0.0001</td><td>0.0</td><td>0.0</td><td>9.16</td><td>9.29</td><td>9.09</td><td>9.24</td><td>9.17</td><td>0.07</td><td>0.7634</td><td>43642.92</td><td>40302.885</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (358, 27)\\n\",\n",
    "       \"┌──────┬─────────┬─────────┬─────────┬───┬────────┬─────────┬─────────┬────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商    ┆ 交易日  ┆ 交易时  ┆ … ┆ change ┆ pct_chg ┆ vol     ┆ amount │\\n\",\n",
    "       \"│ ---  ┆ ---     ┆ 期      ┆ 间      ┆   ┆ ---    ┆ ---     ┆ ---     ┆ ---    │\\n\",\n",
    "       \"│ u32  ┆ str     ┆ ---     ┆ ---     ┆   ┆ f64    ┆ f64     ┆ f64     ┆ f64    │\\n\",\n",
    "       \"│      ┆         ┆ date    ┆ str     ┆   ┆        ┆         ┆         ┆        │\\n\",\n",
    "       \"╞══════╪═════════╪═════════╪═════════╪═══╪════════╪═════════╪═════════╪════════╡\\n\",\n",
    "       \"│ 1    ┆ 湘财    ┆ 2022-07 ┆ 09:33:3 ┆ … ┆ 0.06   ┆ 1.4778  ┆ 89030.6 ┆ 36352. │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 7       ┆   ┆        ┆         ┆ 4       ┆ 212    │\\n\",\n",
    "       \"│ 2    ┆ 湘财    ┆ 2022-07 ┆ 09:34:2 ┆ … ┆ 0.01   ┆ 0.274   ┆ 370994. ┆ 135739 │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 4       ┆   ┆        ┆         ┆ 07      ┆ .515   │\\n\",\n",
    "       \"│ 3    ┆ 湘财    ┆ 2022-07 ┆ 09:36:3 ┆ … ┆ -0.06  ┆ -0.9132 ┆ 20737.5 ┆ 13537. │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 0       ┆   ┆        ┆         ┆         ┆ 134    │\\n\",\n",
    "       \"│ 4    ┆ 湘财    ┆ 2022-07 ┆ 09:37:2 ┆ … ┆ -0.02  ┆ -0.7663 ┆ 247321. ┆ 64052. │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 5       ┆   ┆        ┆         ┆ 0       ┆ 01     │\\n\",\n",
    "       \"│ 5    ┆ 湘财    ┆ 2022-07 ┆ 09:38:1 ┆ … ┆ 0.47   ┆ 3.566   ┆ 62827.0 ┆ 85869. │\\n\",\n",
    "       \"│      ┆         ┆ -11     ┆ 6       ┆   ┆        ┆         ┆         ┆ 11     │\\n\",\n",
    "       \"│ …    ┆ …       ┆ …       ┆ …       ┆ … ┆ …      ┆ …       ┆ …       ┆ …      │\\n\",\n",
    "       \"│ 359  ┆ 海通两  ┆ 2023-10 ┆ 09:31:5 ┆ … ┆ -0.14  ┆ -0.9852 ┆ 17859.2 ┆ 25247. │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆        ┆         ┆         ┆ 849    │\\n\",\n",
    "       \"│ 360  ┆ 海通两  ┆ 2023-10 ┆ 09:39:5 ┆ … ┆ -0.02  ┆ -0.1266 ┆ 18384.1 ┆ 29025. │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 7       ┆   ┆        ┆         ┆ 2       ┆ 236    │\\n\",\n",
    "       \"│ 361  ┆ 海通两  ┆ 2023-10 ┆ 09:40:5 ┆ … ┆ 0.08   ┆ 1.5474  ┆ 88442.0 ┆ 46306. │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆        ┆         ┆ 1       ┆ 236    │\\n\",\n",
    "       \"│ 362  ┆ 海通两  ┆ 2023-10 ┆ 09:43:1 ┆ … ┆ 0.04   ┆ 0.6814  ┆ 40253.0 ┆ 23766. │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 3       ┆   ┆        ┆         ┆         ┆ 196    │\\n\",\n",
    "       \"│ 363  ┆ 海通两  ┆ 2023-10 ┆ 09:44:4 ┆ … ┆ 0.07   ┆ 0.7634  ┆ 43642.9 ┆ 40302. │\\n\",\n",
    "       \"│      ┆ 融      ┆ -31     ┆ 5       ┆   ┆        ┆         ┆ 2       ┆ 885    │\\n\",\n",
    "       \"└──────┴─────────┴─────────┴─────────┴───┴────────┴─────────┴─────────┴────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 119,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d1.join(\\n\",\n",
    "    \"    hq, left_on=[\\\"交易日期\\\", \\\"证券代码\\\"], right_on=[\\\"trade_date\\\", \\\"ts_code\\\"], how=\\\"left\\\"\\n\",\n",
    "    \").filter(\\n\",\n",
    "    \"    pl.col(\\\"成交价格\\\").is_between(pl.col(\\\"low\\\"), pl.col(\\\"high\\\")),\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 121,\n",
    "   \"id\": \"a8605a7d-e386-48a4-aea2-46ca4ec92a0c\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (358, 28)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>序号</th><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th><th>open</th><th>high</th><th>low</th><th>close</th><th>pre_close</th><th>change</th><th>pct_chg</th><th>vol</th><th>amount</th><th>vratio</th></tr><tr><td>u32</td><td>str</td><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>237</td><td>&quot;湘财&quot;</td><td>2023-05-09</td><td>&quot;09:33:16&quot;</td><td>&quot;601166&quot;</td><td>&quot;兴业银行&quot;</td><td>&quot;卖出&quot;</td><td>17.75</td><td>3000.0</td><td>53250.0</td><td>8.52</td><td>53.25</td><td>0.53</td><td>0.0</td><td>53187.7</td><td>0.00016</td><td>0.001</td><td>0.00001</td><td>17.77</td><td>17.94</td><td>17.5</td><td>17.56</td><td>17.63</td><td>-0.07</td><td>-0.3971</td><td>1.6276e6</td><td>2.8810e6</td><td>0.000018</td></tr><tr><td>48</td><td>&quot;湘财&quot;</td><td>2022-10-25</td><td>&quot;09:30:19&quot;</td><td>&quot;300368&quot;</td><td>&quot;汇金股份&quot;</td><td>&quot;卖出&quot;</td><td>6.2</td><td>100.0</td><td>620.0</td><td>0.1</td><td>0.62</td><td>0.01</td><td>0.0</td><td>619.28</td><td>0.000161</td><td>0.001</td><td>0.000016</td><td>6.18</td><td>6.25</td><td>5.95</td><td>6.06</td><td>6.2</td><td>-0.14</td><td>-2.2581</td><td>49219.99</td><td>29911.915</td><td>0.00002</td></tr><tr><td>49</td><td>&quot;湘财&quot;</td><td>2022-10-25</td><td>&quot;09:30:39&quot;</td><td>&quot;002996&quot;</td><td>&quot;顺博合金&quot;</td><td>&quot;卖出&quot;</td><td>13.64</td><td>100.0</td><td>1364.0</td><td>0.22</td><td>1.36</td><td>0.01</td><td>0.0</td><td>1362.42</td><td>0.000161</td><td>0.000997</td><td>0.000007</td><td>13.57</td><td>13.93</td><td>13.26</td><td>13.82</td><td>13.64</td><td>0.18</td><td>1.3196</td><td>38258.22</td><td>52122.119</td><td>0.000026</td></tr><tr><td>235</td><td>&quot;湘财&quot;</td><td>2023-04-25</td><td>&quot;13:35:07&quot;</td><td>&quot;601166&quot;</td><td>&quot;兴业银行&quot;</td><td>&quot;买入&quot;</td><td>17.15</td><td>3000.0</td><td>51450.0</td><td>8.23</td><td>0.0</td><td>0.51</td><td>0.0</td><td>-51458.74</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>16.96</td><td>17.29</td><td>16.96</td><td>17.27</td><td>16.93</td><td>0.34</td><td>2.0083</td><td>995234.22</td><td>1.7071e6</td><td>0.00003</td></tr><tr><td>46</td><td>&quot;湘财&quot;</td><td>2022-10-25</td><td>&quot;09:25:00&quot;</td><td>&quot;002998&quot;</td><td>&quot;优彩资源&quot;</td><td>&quot;卖出&quot;</td><td>6.73</td><td>100.0</td><td>673.0</td><td>0.11</td><td>0.67</td><td>0.01</td><td>0.0</td><td>672.22</td><td>0.000163</td><td>0.000996</td><td>0.000015</td><td>6.73</td><td>6.73</td><td>6.56</td><td>6.64</td><td>6.72</td><td>-0.08</td><td>-1.1905</td><td>16145.0</td><td>10687.614</td><td>0.000062</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>30</td><td>&quot;湘财&quot;</td><td>2022-10-11</td><td>&quot;09:41:06&quot;</td><td>&quot;600231&quot;</td><td>&quot;凌钢股份&quot;</td><td>&quot;买入&quot;</td><td>2.2</td><td>62700.0</td><td>137940.0</td><td>22.07</td><td>0.0</td><td>1.29</td><td>0.0</td><td>-137963.36</td><td>0.00016</td><td>0.0</td><td>0.000009</td><td>2.21</td><td>2.22</td><td>2.15</td><td>2.2</td><td>2.21</td><td>-0.01</td><td>-0.4525</td><td>61371.2</td><td>13386.328</td><td>0.010217</td></tr><tr><td>3</td><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>&quot;09:36:30&quot;</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>6.54</td><td>21400.0</td><td>139956.0</td><td>22.39</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-139979.8</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>6.57</td><td>6.57</td><td>6.49</td><td>6.51</td><td>6.57</td><td>-0.06</td><td>-0.9132</td><td>20737.5</td><td>13537.134</td><td>0.010319</td></tr><tr><td>142</td><td>&quot;湘财&quot;</td><td>2023-02-21</td><td>&quot;09:37:16&quot;</td><td>&quot;300385&quot;</td><td>&quot;雪浪环境&quot;</td><td>&quot;买入&quot;</td><td>6.5293</td><td>11500.0</td><td>75087.0</td><td>12.01</td><td>0.0</td><td>0.77</td><td>0.0</td><td>-75099.01</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>6.53</td><td>6.59</td><td>6.45</td><td>6.52</td><td>6.5</td><td>0.02</td><td>0.3077</td><td>11136.0</td><td>7250.686</td><td>0.010327</td></tr><tr><td>152</td><td>&quot;湘财&quot;</td><td>2023-03-01</td><td>&quot;09:31:46&quot;</td><td>&quot;688069&quot;</td><td>&quot;德林海环保&quot;</td><td>&quot;卖出&quot;</td><td>28.2838</td><td>2600.0</td><td>73538.0</td><td>11.77</td><td>73.58</td><td>0.77</td><td>0.0</td><td>73451.88</td><td>0.00016</td><td>0.001001</td><td>0.00001</td><td>28.52</td><td>28.86</td><td>28.27</td><td>28.67</td><td>28.54</td><td>0.13</td><td>0.4555</td><td>2416.06</td><td>6897.976</td><td>0.010761</td></tr><tr><td>27</td><td>&quot;湘财&quot;</td><td>2022-10-11</td><td>&quot;09:37:32&quot;</td><td>&quot;600261&quot;</td><td>&quot;阳光照明&quot;</td><td>&quot;买入&quot;</td><td>3.1134</td><td>44600.0</td><td>138857.0</td><td>22.22</td><td>0.0</td><td>1.33</td><td>0.0</td><td>-138880.55</td><td>0.00016</td><td>0.0</td><td>0.00001</td><td>3.14</td><td>3.15</td><td>3.06</td><td>3.13</td><td>3.11</td><td>0.02</td><td>0.6431</td><td>41397.03</td><td>12872.499</td><td>0.010774</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (358, 28)\\n\",\n",
    "       \"┌──────┬──────┬──────────┬─────────┬───┬─────────┬─────────┬─────────┬─────────┐\\n\",\n",
    "       \"│ 序号 ┆ 券商 ┆ 交易日期 ┆ 交易时  ┆ … ┆ pct_chg ┆ vol     ┆ amount  ┆ vratio  │\\n\",\n",
    "       \"│ ---  ┆ ---  ┆ ---      ┆ 间      ┆   ┆ ---     ┆ ---     ┆ ---     ┆ ---     │\\n\",\n",
    "       \"│ u32  ┆ str  ┆ date     ┆ ---     ┆   ┆ f64     ┆ f64     ┆ f64     ┆ f64     │\\n\",\n",
    "       \"│      ┆      ┆          ┆ str     ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"╞══════╪══════╪══════════╪═════════╪═══╪═════════╪═════════╪═════════╪═════════╡\\n\",\n",
    "       \"│ 237  ┆ 湘财 ┆ 2023-05- ┆ 09:33:1 ┆ … ┆ -0.3971 ┆ 1.6276e ┆ 2.8810e ┆ 0.00001 │\\n\",\n",
    "       \"│      ┆      ┆ 09       ┆ 6       ┆   ┆         ┆ 6       ┆ 6       ┆ 8       │\\n\",\n",
    "       \"│ 48   ┆ 湘财 ┆ 2022-10- ┆ 09:30:1 ┆ … ┆ -2.2581 ┆ 49219.9 ┆ 29911.9 ┆ 0.00002 │\\n\",\n",
    "       \"│      ┆      ┆ 25       ┆ 9       ┆   ┆         ┆ 9       ┆ 15      ┆         │\\n\",\n",
    "       \"│ 49   ┆ 湘财 ┆ 2022-10- ┆ 09:30:3 ┆ … ┆ 1.3196  ┆ 38258.2 ┆ 52122.1 ┆ 0.00002 │\\n\",\n",
    "       \"│      ┆      ┆ 25       ┆ 9       ┆   ┆         ┆ 2       ┆ 19      ┆ 6       │\\n\",\n",
    "       \"│ 235  ┆ 湘财 ┆ 2023-04- ┆ 13:35:0 ┆ … ┆ 2.0083  ┆ 995234. ┆ 1.7071e ┆ 0.00003 │\\n\",\n",
    "       \"│      ┆      ┆ 25       ┆ 7       ┆   ┆         ┆ 22      ┆ 6       ┆         │\\n\",\n",
    "       \"│ 46   ┆ 湘财 ┆ 2022-10- ┆ 09:25:0 ┆ … ┆ -1.1905 ┆ 16145.0 ┆ 10687.6 ┆ 0.00006 │\\n\",\n",
    "       \"│      ┆      ┆ 25       ┆ 0       ┆   ┆         ┆         ┆ 14      ┆ 2       │\\n\",\n",
    "       \"│ …    ┆ …    ┆ …        ┆ …       ┆ … ┆ …       ┆ …       ┆ …       ┆ …       │\\n\",\n",
    "       \"│ 30   ┆ 湘财 ┆ 2022-10- ┆ 09:41:0 ┆ … ┆ -0.4525 ┆ 61371.2 ┆ 13386.3 ┆ 0.01021 │\\n\",\n",
    "       \"│      ┆      ┆ 11       ┆ 6       ┆   ┆         ┆         ┆ 28      ┆ 7       │\\n\",\n",
    "       \"│ 3    ┆ 湘财 ┆ 2022-07- ┆ 09:36:3 ┆ … ┆ -0.9132 ┆ 20737.5 ┆ 13537.1 ┆ 0.01031 │\\n\",\n",
    "       \"│      ┆      ┆ 11       ┆ 0       ┆   ┆         ┆         ┆ 34      ┆ 9       │\\n\",\n",
    "       \"│ 142  ┆ 湘财 ┆ 2023-02- ┆ 09:37:1 ┆ … ┆ 0.3077  ┆ 11136.0 ┆ 7250.68 ┆ 0.01032 │\\n\",\n",
    "       \"│      ┆      ┆ 21       ┆ 6       ┆   ┆         ┆         ┆ 6       ┆ 7       │\\n\",\n",
    "       \"│ 152  ┆ 湘财 ┆ 2023-03- ┆ 09:31:4 ┆ … ┆ 0.4555  ┆ 2416.06 ┆ 6897.97 ┆ 0.01076 │\\n\",\n",
    "       \"│      ┆      ┆ 01       ┆ 6       ┆   ┆         ┆         ┆ 6       ┆ 1       │\\n\",\n",
    "       \"│ 27   ┆ 湘财 ┆ 2022-10- ┆ 09:37:3 ┆ … ┆ 0.6431  ┆ 41397.0 ┆ 12872.4 ┆ 0.01077 │\\n\",\n",
    "       \"│      ┆      ┆ 11       ┆ 2       ┆   ┆         ┆ 3       ┆ 99      ┆ 4       │\\n\",\n",
    "       \"└──────┴──────┴──────────┴─────────┴───┴─────────┴─────────┴─────────┴─────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 121,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d1.join(\\n\",\n",
    "    \"    hq, left_on=[\\\"交易日期\\\", \\\"证券代码\\\"], right_on=[\\\"trade_date\\\", \\\"ts_code\\\"], how=\\\"left\\\"\\n\",\n",
    "    \").with_columns(\\n\",\n",
    "    \"    vratio=pl.col(\\\"成交数量\\\") / 100 / pl.col(\\\"vol\\\"),\\n\",\n",
    "    \").sort(\\\"vratio\\\")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 123,\n",
    "   \"id\": \"ebf5a5d4-568b-41f1-a767-7d5d106c3f60\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (72_671, 19)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>交易日期</th><th>证券代码</th><th>序号</th><th>券商</th><th>交易时间</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>手续费率</th><th>印花税率</th><th>过户费率</th><th>结余数量</th></tr><tr><td>date</td><td>str</td><td>u32</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>2022-07-11</td><td>&quot;000096&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>2022-07-11</td><td>&quot;000532&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>2022-07-11</td><td>&quot;000559&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>2022-07-11</td><td>&quot;000599&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>2022-07-11</td><td>&quot;000655&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2023-10-31</td><td>&quot;688299&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>2023-10-31</td><td>&quot;688321&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>2023-10-31</td><td>&quot;688360&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>2023-10-31</td><td>&quot;688393&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>0.0</td></tr><tr><td>2023-10-31</td><td>&quot;688660&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>20200.0</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (72_671, 19)\\n\",\n",
    "       \"┌──────────┬─────────┬──────┬──────┬───┬─────────┬─────────┬─────────┬─────────┐\\n\",\n",
    "       \"│ 交易日期 ┆ 证券代  ┆ 序号 ┆ 券商 ┆ … ┆ 手续费  ┆ 印花税  ┆ 过户费  ┆ 结余数  │\\n\",\n",
    "       \"│ ---      ┆ 码      ┆ ---  ┆ ---  ┆   ┆ 率      ┆ 率      ┆ 率      ┆ 量      │\\n\",\n",
    "       \"│ date     ┆ ---     ┆ u32  ┆ str  ┆   ┆ ---     ┆ ---     ┆ ---     ┆ ---     │\\n\",\n",
    "       \"│          ┆ str     ┆      ┆      ┆   ┆ f64     ┆ f64     ┆ f64     ┆ f64     │\\n\",\n",
    "       \"╞══════════╪═════════╪══════╪══════╪═══╪═════════╪═════════╪═════════╪═════════╡\\n\",\n",
    "       \"│ 2022-07- ┆ 000096  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 11       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ 2022-07- ┆ 000532  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 11       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ 2022-07- ┆ 000559  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 11       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ 2022-07- ┆ 000599  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 11       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ 2022-07- ┆ 000655  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 11       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ …        ┆ …       ┆ …    ┆ …    ┆ … ┆ …       ┆ …       ┆ …       ┆ …       │\\n\",\n",
    "       \"│ 2023-10- ┆ 688299  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 31       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ 2023-10- ┆ 688321  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 31       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ 2023-10- ┆ 688360  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 31       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ 2023-10- ┆ 688393  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 0.0     │\\n\",\n",
    "       \"│ 31       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"│ 2023-10- ┆ 688660  ┆ null ┆ null ┆ … ┆ null    ┆ null    ┆ null    ┆ 20200.0 │\\n\",\n",
    "       \"│ 31       ┆         ┆      ┆      ┆   ┆         ┆         ┆         ┆         │\\n\",\n",
    "       \"└──────────┴─────────┴──────┴──────┴───┴─────────┴─────────┴─────────┴─────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 123,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d3 = (\\n\",\n",
    "    \"    k.join(\\n\",\n",
    "    \"        d1,\\n\",\n",
    "    \"        left_on=[\\\"交易日期\\\", \\\"证券代码\\\"],\\n\",\n",
    "    \"        right_on=[\\\"交易日期\\\", \\\"证券代码\\\"],\\n\",\n",
    "    \"        how=\\\"left\\\",\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .sort(\\\"交易日期\\\", \\\"证券代码\\\")\\n\",\n",
    "    \"    .with_columns(\\n\",\n",
    "    \"        结余数量=(\\n\",\n",
    "    \"            pl.when(pl.col(\\\"买卖标志\\\") == \\\"卖出\\\")\\n\",\n",
    "    \"            .then(-pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .when(pl.col(\\\"买卖标志\\\") == \\\"买入\\\")\\n\",\n",
    "    \"            .then(pl.col(\\\"成交数量\\\"))\\n\",\n",
    "    \"            .otherwise(0)\\n\",\n",
    "    \"            .cum_sum()\\n\",\n",
    "    \"            .over(\\\"证券代码\\\")\\n\",\n",
    "    \"        ),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \")\\n\",\n",
    "    \"d3\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 127,\n",
    "   \"id\": \"a2825bc9-2858-416c-b05f-6ab0cba6aba0\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (7, 2)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>a</th><th>b</th></tr><tr><td>i64</td><td>i64</td></tr></thead><tbody><tr><td>2</td><td>2</td></tr><tr><td>8</td><td>8</td></tr><tr><td>null</td><td>1</td></tr><tr><td>1</td><td>1</td></tr><tr><td>null</td><td>9</td></tr><tr><td>9</td><td>9</td></tr><tr><td>null</td><td>null</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (7, 2)\\n\",\n",
    "       \"┌──────┬──────┐\\n\",\n",
    "       \"│ a    ┆ b    │\\n\",\n",
    "       \"│ ---  ┆ ---  │\\n\",\n",
    "       \"│ i64  ┆ i64  │\\n\",\n",
    "       \"╞══════╪══════╡\\n\",\n",
    "       \"│ 2    ┆ 2    │\\n\",\n",
    "       \"│ 8    ┆ 8    │\\n\",\n",
    "       \"│ null ┆ 1    │\\n\",\n",
    "       \"│ 1    ┆ 1    │\\n\",\n",
    "       \"│ null ┆ 9    │\\n\",\n",
    "       \"│ 9    ┆ 9    │\\n\",\n",
    "       \"│ null ┆ null │\\n\",\n",
    "       \"└──────┴──────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 127,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"pl.DataFrame({\\\"a\\\": [2, 8, None, 1, None, 9, None]}).with_columns(\\n\",\n",
    "    \"    b=pl.col.a.fill_null(strategy=\\\"backward\\\")\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 128,\n",
    "   \"id\": \"f398ba8e-20b4-46ef-9221-9cc0ee8aad74\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (47_355, 11)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>ts_code</th><th>trade_date</th><th>open</th><th>high</th><th>low</th><th>close</th><th>pre_close</th><th>change</th><th>pct_chg</th><th>vol</th><th>amount</th></tr><tr><td>str</td><td>date</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;000096&quot;</td><td>2023-10-31</td><td>8.95</td><td>9.25</td><td>8.88</td><td>8.95</td><td>8.84</td><td>0.11</td><td>1.2443</td><td>45191.22</td><td>40697.722</td></tr><tr><td>&quot;000096&quot;</td><td>2023-10-30</td><td>8.72</td><td>8.94</td><td>8.68</td><td>8.84</td><td>8.78</td><td>0.06</td><td>0.6834</td><td>33567.85</td><td>29716.156</td></tr><tr><td>&quot;000096&quot;</td><td>2023-10-27</td><td>8.97</td><td>8.98</td><td>8.75</td><td>8.78</td><td>8.94</td><td>-0.16</td><td>-1.7897</td><td>30035.5</td><td>26547.822</td></tr><tr><td>&quot;000096&quot;</td><td>2023-10-26</td><td>9.12</td><td>9.13</td><td>8.83</td><td>8.94</td><td>9.06</td><td>-0.12</td><td>-1.3245</td><td>28794.0</td><td>25735.179</td></tr><tr><td>&quot;000096&quot;</td><td>2023-10-25</td><td>9.04</td><td>9.2</td><td>8.92</td><td>9.06</td><td>8.99</td><td>0.07</td><td>0.7786</td><td>31960.0</td><td>29019.019</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;688660&quot;</td><td>2022-07-15</td><td>9.73</td><td>10.11</td><td>9.65</td><td>9.76</td><td>9.73</td><td>0.03</td><td>0.3083</td><td>338386.93</td><td>334715.635</td></tr><tr><td>&quot;688660&quot;</td><td>2022-07-14</td><td>9.67</td><td>9.84</td><td>9.55</td><td>9.73</td><td>9.67</td><td>0.06</td><td>0.6205</td><td>329943.3</td><td>319289.544</td></tr><tr><td>&quot;688660&quot;</td><td>2022-07-13</td><td>9.06</td><td>9.86</td><td>9.0</td><td>9.67</td><td>9.06</td><td>0.61</td><td>6.7329</td><td>550236.58</td><td>524088.481</td></tr><tr><td>&quot;688660&quot;</td><td>2022-07-12</td><td>8.99</td><td>9.39</td><td>8.89</td><td>9.06</td><td>9.04</td><td>0.02</td><td>0.2212</td><td>288562.46</td><td>264062.174</td></tr><tr><td>&quot;688660&quot;</td><td>2022-07-11</td><td>9.0</td><td>9.2</td><td>8.89</td><td>9.04</td><td>9.02</td><td>0.02</td><td>0.2217</td><td>166819.63</td><td>150747.732</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (47_355, 11)\\n\",\n",
    "       \"┌─────────┬──────────┬──────┬───────┬───┬────────┬─────────┬─────────┬─────────┐\\n\",\n",
    "       \"│ ts_code ┆ trade_da ┆ open ┆ high  ┆ … ┆ change ┆ pct_chg ┆ vol     ┆ amount  │\\n\",\n",
    "       \"│ ---     ┆ te       ┆ ---  ┆ ---   ┆   ┆ ---    ┆ ---     ┆ ---     ┆ ---     │\\n\",\n",
    "       \"│ str     ┆ ---      ┆ f64  ┆ f64   ┆   ┆ f64    ┆ f64     ┆ f64     ┆ f64     │\\n\",\n",
    "       \"│         ┆ date     ┆      ┆       ┆   ┆        ┆         ┆         ┆         │\\n\",\n",
    "       \"╞═════════╪══════════╪══════╪═══════╪═══╪════════╪═════════╪═════════╪═════════╡\\n\",\n",
    "       \"│ 000096  ┆ 2023-10- ┆ 8.95 ┆ 9.25  ┆ … ┆ 0.11   ┆ 1.2443  ┆ 45191.2 ┆ 40697.7 │\\n\",\n",
    "       \"│         ┆ 31       ┆      ┆       ┆   ┆        ┆         ┆ 2       ┆ 22      │\\n\",\n",
    "       \"│ 000096  ┆ 2023-10- ┆ 8.72 ┆ 8.94  ┆ … ┆ 0.06   ┆ 0.6834  ┆ 33567.8 ┆ 29716.1 │\\n\",\n",
    "       \"│         ┆ 30       ┆      ┆       ┆   ┆        ┆         ┆ 5       ┆ 56      │\\n\",\n",
    "       \"│ 000096  ┆ 2023-10- ┆ 8.97 ┆ 8.98  ┆ … ┆ -0.16  ┆ -1.7897 ┆ 30035.5 ┆ 26547.8 │\\n\",\n",
    "       \"│         ┆ 27       ┆      ┆       ┆   ┆        ┆         ┆         ┆ 22      │\\n\",\n",
    "       \"│ 000096  ┆ 2023-10- ┆ 9.12 ┆ 9.13  ┆ … ┆ -0.12  ┆ -1.3245 ┆ 28794.0 ┆ 25735.1 │\\n\",\n",
    "       \"│         ┆ 26       ┆      ┆       ┆   ┆        ┆         ┆         ┆ 79      │\\n\",\n",
    "       \"│ 000096  ┆ 2023-10- ┆ 9.04 ┆ 9.2   ┆ … ┆ 0.07   ┆ 0.7786  ┆ 31960.0 ┆ 29019.0 │\\n\",\n",
    "       \"│         ┆ 25       ┆      ┆       ┆   ┆        ┆         ┆         ┆ 19      │\\n\",\n",
    "       \"│ …       ┆ …        ┆ …    ┆ …     ┆ … ┆ …      ┆ …       ┆ …       ┆ …       │\\n\",\n",
    "       \"│ 688660  ┆ 2022-07- ┆ 9.73 ┆ 10.11 ┆ … ┆ 0.03   ┆ 0.3083  ┆ 338386. ┆ 334715. │\\n\",\n",
    "       \"│         ┆ 15       ┆      ┆       ┆   ┆        ┆         ┆ 93      ┆ 635     │\\n\",\n",
    "       \"│ 688660  ┆ 2022-07- ┆ 9.67 ┆ 9.84  ┆ … ┆ 0.06   ┆ 0.6205  ┆ 329943. ┆ 319289. │\\n\",\n",
    "       \"│         ┆ 14       ┆      ┆       ┆   ┆        ┆         ┆ 3       ┆ 544     │\\n\",\n",
    "       \"│ 688660  ┆ 2022-07- ┆ 9.06 ┆ 9.86  ┆ … ┆ 0.61   ┆ 6.7329  ┆ 550236. ┆ 524088. │\\n\",\n",
    "       \"│         ┆ 13       ┆      ┆       ┆   ┆        ┆         ┆ 58      ┆ 481     │\\n\",\n",
    "       \"│ 688660  ┆ 2022-07- ┆ 8.99 ┆ 9.39  ┆ … ┆ 0.02   ┆ 0.2212  ┆ 288562. ┆ 264062. │\\n\",\n",
    "       \"│         ┆ 12       ┆      ┆       ┆   ┆        ┆         ┆ 46      ┆ 174     │\\n\",\n",
    "       \"│ 688660  ┆ 2022-07- ┆ 9.0  ┆ 9.2   ┆ … ┆ 0.02   ┆ 0.2217  ┆ 166819. ┆ 150747. │\\n\",\n",
    "       \"│         ┆ 11       ┆      ┆       ┆   ┆        ┆         ┆ 63      ┆ 732     │\\n\",\n",
    "       \"└─────────┴──────────┴──────┴───────┴───┴────────┴─────────┴─────────┴─────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 128,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"hq\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 162,\n",
    "   \"id\": \"0b484d36-58a9-41dc-95cc-0c6107fb9be0\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (478, 6)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>交易日期</th><th>持股市值</th><th>发生金额</th><th>转账金额</th><th>现金余额</th><th>总资产</th></tr><tr><td>date</td><td>f64</td><td>f64</td><td>i32</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>2022-07-11</td><td>703040.0</td><td>-699551.12</td><td>1000000</td><td>300448.88</td><td>1.0035e6</td></tr><tr><td>2022-07-12</td><td>707714.0</td><td>0.0</td><td>0</td><td>300448.88</td><td>1.0082e6</td></tr><tr><td>2022-07-13</td><td>713855.0</td><td>0.0</td><td>0</td><td>300448.88</td><td>1.0143e6</td></tr><tr><td>2022-07-14</td><td>710079.0</td><td>0.0</td><td>0</td><td>300448.88</td><td>1.0105e6</td></tr><tr><td>2022-07-15</td><td>692377.0</td><td>0.0</td><td>0</td><td>300448.88</td><td>992825.88</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2023-10-27</td><td>571195.0</td><td>0.0</td><td>0</td><td>510845.96</td><td>1.0820e6</td></tr><tr><td>2023-10-28</td><td>571195.0</td><td>0.0</td><td>0</td><td>510845.96</td><td>1.0820e6</td></tr><tr><td>2023-10-29</td><td>571195.0</td><td>0.0</td><td>0</td><td>510845.96</td><td>1.0820e6</td></tr><tr><td>2023-10-30</td><td>686345.0</td><td>-94884.93</td><td>0</td><td>415961.03</td><td>1.1023e6</td></tr><tr><td>2023-10-31</td><td>748947.0</td><td>6490.78</td><td>0</td><td>422451.81</td><td>1.1714e6</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (478, 6)\\n\",\n",
    "       \"┌────────────┬──────────┬────────────┬──────────┬───────────┬───────────┐\\n\",\n",
    "       \"│ 交易日期   ┆ 持股市值 ┆ 发生金额   ┆ 转账金额 ┆ 现金余额  ┆ 总资产    │\\n\",\n",
    "       \"│ ---        ┆ ---      ┆ ---        ┆ ---      ┆ ---       ┆ ---       │\\n\",\n",
    "       \"│ date       ┆ f64      ┆ f64        ┆ i32      ┆ f64       ┆ f64       │\\n\",\n",
    "       \"╞════════════╪══════════╪════════════╪══════════╪═══════════╪═══════════╡\\n\",\n",
    "       \"│ 2022-07-11 ┆ 703040.0 ┆ -699551.12 ┆ 1000000  ┆ 300448.88 ┆ 1.0035e6  │\\n\",\n",
    "       \"│ 2022-07-12 ┆ 707714.0 ┆ 0.0        ┆ 0        ┆ 300448.88 ┆ 1.0082e6  │\\n\",\n",
    "       \"│ 2022-07-13 ┆ 713855.0 ┆ 0.0        ┆ 0        ┆ 300448.88 ┆ 1.0143e6  │\\n\",\n",
    "       \"│ 2022-07-14 ┆ 710079.0 ┆ 0.0        ┆ 0        ┆ 300448.88 ┆ 1.0105e6  │\\n\",\n",
    "       \"│ 2022-07-15 ┆ 692377.0 ┆ 0.0        ┆ 0        ┆ 300448.88 ┆ 992825.88 │\\n\",\n",
    "       \"│ …          ┆ …        ┆ …          ┆ …        ┆ …         ┆ …         │\\n\",\n",
    "       \"│ 2023-10-27 ┆ 571195.0 ┆ 0.0        ┆ 0        ┆ 510845.96 ┆ 1.0820e6  │\\n\",\n",
    "       \"│ 2023-10-28 ┆ 571195.0 ┆ 0.0        ┆ 0        ┆ 510845.96 ┆ 1.0820e6  │\\n\",\n",
    "       \"│ 2023-10-29 ┆ 571195.0 ┆ 0.0        ┆ 0        ┆ 510845.96 ┆ 1.0820e6  │\\n\",\n",
    "       \"│ 2023-10-30 ┆ 686345.0 ┆ -94884.93  ┆ 0        ┆ 415961.03 ┆ 1.1023e6  │\\n\",\n",
    "       \"│ 2023-10-31 ┆ 748947.0 ┆ 6490.78    ┆ 0        ┆ 422451.81 ┆ 1.1714e6  │\\n\",\n",
    "       \"└────────────┴──────────┴────────────┴──────────┴───────────┴───────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 162,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d4 = (\\n\",\n",
    "    \"    d3.join(\\n\",\n",
    "    \"        hq,\\n\",\n",
    "    \"        left_on=[\\\"交易日期\\\", \\\"证券代码\\\"],\\n\",\n",
    "    \"        right_on=[\\\"trade_date\\\", \\\"ts_code\\\"],\\n\",\n",
    "    \"        how=\\\"left\\\",\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .sort(\\\"证券代码\\\", \\\"交易日期\\\")\\n\",\n",
    "    \"    .with_columns(close=pl.col(\\\"close\\\").fill_null(strategy=\\\"forward\\\").over(\\\"证券代码\\\"))\\n\",\n",
    "    \"    .with_columns(\\n\",\n",
    "    \"        持股市值=pl.col(\\\"结余数量\\\") * pl.col(\\\"close\\\"),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .group_by(\\\"交易日期\\\")\\n\",\n",
    "    \"    .agg(\\n\",\n",
    "    \"        pl.col(\\\"持股市值\\\").sum(),\\n\",\n",
    "    \"        pl.col(\\\"发生金额\\\").sum(),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .sort(\\\"交易日期\\\")\\n\",\n",
    "    \"    .with_columns(\\n\",\n",
    "    \"        转账金额=pl.when(pl.int_range(0, pl.len()) == 0).then(100_0000).otherwise(0),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .with_columns(\\n\",\n",
    "    \"        现金余额=(pl.col(\\\"转账金额\\\") + pl.col(\\\"发生金额\\\")).cum_sum(),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .with_columns(总资产=pl.col(\\\"持股市值\\\") + pl.col(\\\"现金余额\\\"))\\n\",\n",
    "    \")\\n\",\n",
    "    \"d4\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 163,\n",
    "   \"id\": \"99e95a71-618f-49f0-98ad-f58776c9f10e\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"application/vnd.jupyter.widget-view+json\": {\n",
    "       \"model_id\": \"f82afccd652e4710b0c05da5bc969b90\",\n",
    "       \"version_major\": 2,\n",
    "       \"version_minor\": 0\n",
    "      },\n",
    "      \"text/plain\": [\n",
    "       \"PerspectiveWidget(binding_mode='server', columns=['交易日期', '持股市值', '发生金额', '转账金额', '现金余额', '总资产'], table_name='…\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 163,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"PerspectiveWidget(d4)\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 167,\n",
    "   \"id\": \"30e56681-b66d-43c8-918a-a82b692b59e2\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"ihq = pro.index_daily(\\n\",\n",
    "    \"    ts_code=\\\"000300.SH\\\",\\n\",\n",
    "    \"    start_date=format(start_date, \\\"%Y%m%d\\\"),\\n\",\n",
    "    \"    end_date=format(end_date, \\\"%Y%m%d\\\"),\\n\",\n",
    "    \"    fields=\\\"ts_code,trade_date,pct_chg\\\",\\n\",\n",
    "    \")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 168,\n",
    "   \"id\": \"feb13aec-2f34-4a27-9b9f-43b07ec74c78\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": [\n",
    "    \"pl.from_pandas(ihq).write_parquet(\\\"index_daily.parquet\\\")\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 177,\n",
    "   \"id\": \"fbf3ce55-52c1-4718-a931-c30a7fb5dff3\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (318, 5)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>ts_code</th><th>trade_date</th><th>pct_chg</th><th>car</th><th>沪深300</th></tr><tr><td>str</td><td>date</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;000300.SH&quot;</td><td>2022-07-11</td><td>0.983254</td><td>0.983254</td><td>983254.0</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2022-07-12</td><td>0.990585</td><td>0.973997</td><td>973996.66359</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2022-07-13</td><td>1.001818</td><td>0.975767</td><td>975767.389524</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2022-07-14</td><td>1.000142</td><td>0.975906</td><td>975905.948494</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2022-07-15</td><td>0.982983</td><td>0.959299</td><td>959298.956968</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2023-10-25</td><td>1.004969</td><td>0.791288</td><td>791288.453778</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2023-10-26</td><td>1.002764</td><td>0.793476</td><td>793475.575065</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2023-10-27</td><td>1.013727</td><td>0.804368</td><td>804367.614284</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2023-10-30</td><td>1.006003</td><td>0.809196</td><td>809196.233072</td></tr><tr><td>&quot;000300.SH&quot;</td><td>2023-10-31</td><td>0.996856</td><td>0.806652</td><td>806652.120115</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (318, 5)\\n\",\n",
    "       \"┌───────────┬────────────┬──────────┬──────────┬───────────────┐\\n\",\n",
    "       \"│ ts_code   ┆ trade_date ┆ pct_chg  ┆ car      ┆ 沪深300       │\\n\",\n",
    "       \"│ ---       ┆ ---        ┆ ---      ┆ ---      ┆ ---           │\\n\",\n",
    "       \"│ str       ┆ date       ┆ f64      ┆ f64      ┆ f64           │\\n\",\n",
    "       \"╞═══════════╪════════════╪══════════╪══════════╪═══════════════╡\\n\",\n",
    "       \"│ 000300.SH ┆ 2022-07-11 ┆ 0.983254 ┆ 0.983254 ┆ 983254.0      │\\n\",\n",
    "       \"│ 000300.SH ┆ 2022-07-12 ┆ 0.990585 ┆ 0.973997 ┆ 973996.66359  │\\n\",\n",
    "       \"│ 000300.SH ┆ 2022-07-13 ┆ 1.001818 ┆ 0.975767 ┆ 975767.389524 │\\n\",\n",
    "       \"│ 000300.SH ┆ 2022-07-14 ┆ 1.000142 ┆ 0.975906 ┆ 975905.948494 │\\n\",\n",
    "       \"│ 000300.SH ┆ 2022-07-15 ┆ 0.982983 ┆ 0.959299 ┆ 959298.956968 │\\n\",\n",
    "       \"│ …         ┆ …          ┆ …        ┆ …        ┆ …             │\\n\",\n",
    "       \"│ 000300.SH ┆ 2023-10-25 ┆ 1.004969 ┆ 0.791288 ┆ 791288.453778 │\\n\",\n",
    "       \"│ 000300.SH ┆ 2023-10-26 ┆ 1.002764 ┆ 0.793476 ┆ 793475.575065 │\\n\",\n",
    "       \"│ 000300.SH ┆ 2023-10-27 ┆ 1.013727 ┆ 0.804368 ┆ 804367.614284 │\\n\",\n",
    "       \"│ 000300.SH ┆ 2023-10-30 ┆ 1.006003 ┆ 0.809196 ┆ 809196.233072 │\\n\",\n",
    "       \"│ 000300.SH ┆ 2023-10-31 ┆ 0.996856 ┆ 0.806652 ┆ 806652.120115 │\\n\",\n",
    "       \"└───────────┴────────────┴──────────┴──────────┴───────────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 177,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"ihq = pl.read_parquet(\\\"index_daily.parquet\\\")\\n\",\n",
    "    \"ihq = (\\n\",\n",
    "    \"    ihq.with_columns(\\n\",\n",
    "    \"        pl.col(\\\"trade_date\\\").str.to_date(\\\"%Y%m%d\\\"),\\n\",\n",
    "    \"        pl.col(\\\"pct_chg\\\") / 100 + 1,\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .sort(\\\"trade_date\\\")\\n\",\n",
    "    \"    .with_columns(\\n\",\n",
    "    \"        car=pl.col(\\\"pct_chg\\\").cum_prod(),\\n\",\n",
    "    \"    )\\n\",\n",
    "    \"    .with_columns(\\n\",\n",
    "    \"        沪深300=pl.col(\\\"car\\\") * 100_0000,\\n\",\n",
    "    \"    )\\n\",\n",
    "    \")\\n\",\n",
    "    \"ihq\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 178,\n",
    "   \"id\": \"9871a0ce-ee4b-43e3-974a-91d38ff576b4\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"application/vnd.jupyter.widget-view+json\": {\n",
    "       \"model_id\": \"b8373a237639454786b60a0d68b00ec9\",\n",
    "       \"version_major\": 2,\n",
    "       \"version_minor\": 0\n",
    "      },\n",
    "      \"text/plain\": [\n",
    "       \"PerspectiveWidget(binding_mode='server', columns=['ts_code', 'trade_date', 'pct_chg', 'car', '沪深300'], table_n…\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 178,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"PerspectiveWidget(ihq)\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 186,\n",
    "   \"id\": \"36e9a75c-1f00-4f25-a254-25e338ebf88d\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"text/html\": [\n",
    "       \"<div><style>\\n\",\n",
    "       \".dataframe > thead > tr,\\n\",\n",
    "       \".dataframe > tbody > tr {\\n\",\n",
    "       \"  text-align: right;\\n\",\n",
    "       \"  white-space: pre-wrap;\\n\",\n",
    "       \"}\\n\",\n",
    "       \"</style>\\n\",\n",
    "       \"<small>shape: (636, 3)</small><table border=\\\"1\\\" class=\\\"dataframe\\\"><thead><tr><th>交易日期</th><th>资产类型</th><th>财富</th></tr><tr><td>date</td><td>str</td><td>f64</td></tr></thead><tbody><tr><td>2022-07-11</td><td>&quot;总资产&quot;</td><td>1.0035e6</td></tr><tr><td>2022-07-12</td><td>&quot;总资产&quot;</td><td>1.0082e6</td></tr><tr><td>2022-07-13</td><td>&quot;总资产&quot;</td><td>1.0143e6</td></tr><tr><td>2022-07-14</td><td>&quot;总资产&quot;</td><td>1.0105e6</td></tr><tr><td>2022-07-15</td><td>&quot;总资产&quot;</td><td>992825.88</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2023-10-25</td><td>&quot;沪深300&quot;</td><td>791288.453778</td></tr><tr><td>2023-10-26</td><td>&quot;沪深300&quot;</td><td>793475.575065</td></tr><tr><td>2023-10-27</td><td>&quot;沪深300&quot;</td><td>804367.614284</td></tr><tr><td>2023-10-30</td><td>&quot;沪深300&quot;</td><td>809196.233072</td></tr><tr><td>2023-10-31</td><td>&quot;沪深300&quot;</td><td>806652.120115</td></tr></tbody></table></div>\"\n",
    "      ],\n",
    "      \"text/plain\": [\n",
    "       \"shape: (636, 3)\\n\",\n",
    "       \"┌────────────┬──────────┬───────────────┐\\n\",\n",
    "       \"│ 交易日期   ┆ 资产类型 ┆ 财富          │\\n\",\n",
    "       \"│ ---        ┆ ---      ┆ ---           │\\n\",\n",
    "       \"│ date       ┆ str      ┆ f64           │\\n\",\n",
    "       \"╞════════════╪══════════╪═══════════════╡\\n\",\n",
    "       \"│ 2022-07-11 ┆ 总资产   ┆ 1.0035e6      │\\n\",\n",
    "       \"│ 2022-07-12 ┆ 总资产   ┆ 1.0082e6      │\\n\",\n",
    "       \"│ 2022-07-13 ┆ 总资产   ┆ 1.0143e6      │\\n\",\n",
    "       \"│ 2022-07-14 ┆ 总资产   ┆ 1.0105e6      │\\n\",\n",
    "       \"│ 2022-07-15 ┆ 总资产   ┆ 992825.88     │\\n\",\n",
    "       \"│ …          ┆ …        ┆ …             │\\n\",\n",
    "       \"│ 2023-10-25 ┆ 沪深300  ┆ 791288.453778 │\\n\",\n",
    "       \"│ 2023-10-26 ┆ 沪深300  ┆ 793475.575065 │\\n\",\n",
    "       \"│ 2023-10-27 ┆ 沪深300  ┆ 804367.614284 │\\n\",\n",
    "       \"│ 2023-10-30 ┆ 沪深300  ┆ 809196.233072 │\\n\",\n",
    "       \"│ 2023-10-31 ┆ 沪深300  ┆ 806652.120115 │\\n\",\n",
    "       \"└────────────┴──────────┴───────────────┘\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 186,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"d5 = d4.join(\\n\",\n",
    "    \"    ihq,\\n\",\n",
    "    \"    left_on=\\\"交易日期\\\",\\n\",\n",
    "    \"    right_on=\\\"trade_date\\\",\\n\",\n",
    "    \")\\n\",\n",
    "    \"d5 = d5.unpivot(\\n\",\n",
    "    \"    on=[\\\"总资产\\\", \\\"沪深300\\\"],\\n\",\n",
    "    \"    index=\\\"交易日期\\\",\\n\",\n",
    "    \"    variable_name=\\\"资产类型\\\",\\n\",\n",
    "    \"    value_name=\\\"财富\\\",\\n\",\n",
    "    \")\\n\",\n",
    "    \"d5\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": 188,\n",
    "   \"id\": \"952f167e-fe39-4294-9a20-180199ee1266\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [\n",
    "    {\n",
    "     \"data\": {\n",
    "      \"application/vnd.jupyter.widget-view+json\": {\n",
    "       \"model_id\": \"bfa0c60ad8734e0ea619f5538407b604\",\n",
    "       \"version_major\": 2,\n",
    "       \"version_minor\": 0\n",
    "      },\n",
    "      \"text/plain\": [\n",
    "       \"PerspectiveWidget(binding_mode='server', columns=['交易日期', '资产类型', '财富'], table_name='0.6572100757167281', them…\"\n",
    "      ]\n",
    "     },\n",
    "     \"execution_count\": 188,\n",
    "     \"metadata\": {},\n",
    "     \"output_type\": \"execute_result\"\n",
    "    }\n",
    "   ],\n",
    "   \"source\": [\n",
    "    \"PerspectiveWidget(d5)\"\n",
    "   ]\n",
    "  },\n",
    "  {\n",
    "   \"cell_type\": \"code\",\n",
    "   \"execution_count\": null,\n",
    "   \"id\": \"b668ae27-1bcb-4460-b8ea-b2450d96a8c3\",\n",
    "   \"metadata\": {},\n",
    "   \"outputs\": [],\n",
    "   \"source\": []\n",
    "  }\n",
    " ],\n",
    " \"metadata\": {\n",
    "  \"kernelspec\": {\n",
    "   \"display_name\": \"Python 3 (ipykernel)\",\n",
    "   \"language\": \"python\",\n",
    "   \"name\": \"python3\"\n",
    "  },\n",
    "  \"language_info\": {\n",
    "   \"codemirror_mode\": {\n",
    "    \"name\": \"ipython\",\n",
    "    \"version\": 3\n",
    "   },\n",
    "   \"file_extension\": \".py\",\n",
    "   \"mimetype\": \"text/x-python\",\n",
    "   \"name\": \"python\",\n",
    "   \"nbconvert_exporter\": \"python\",\n",
    "   \"pygments_lexer\": \"ipython3\",\n",
    "   \"version\": \"3.12.10\"\n",
    "  }\n",
    " },\n",
    " \"nbformat\": 4,\n",
    " \"nbformat_minor\": 5\n",
    "}\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
